Skip to content
Snippets Groups Projects
Commit 72627e42 authored by Philipp Frank's avatar Philipp Frank
Browse files

fixup

parent 873e5a29
Branches
No related tags found
No related merge requests found
Pipeline #148620 passed
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Nifty tutorial for Poisson count data Nifty tutorial for Poisson count data
===================================== =====================================
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Setup Setup
----- -----
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import nifty8 as ift import nifty8 as ift
from utils import plot_2D, load_psf, geovi_sampling, plot_posterior from utils import plot_2D, load_psf, geovi_sampling, plot_posterior
ift.random.push_sseq_from_seed(42) ift.random.push_sseq_from_seed(42)
evidences = np.zeros(3) evidences = np.zeros(3)
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# Load data and visualize # Load data and visualize
data = np.load('data/poisson.npz') data = np.load('data/poisson.npz')
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
position_space = ift.RGSpace([128, 128]) position_space = ift.RGSpace([128, 128])
# Homogeneous poisson process # Homogeneous poisson process
print(model1) print(model1)
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# Set up likelihood & PSF # Set up likelihood & PSF
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# Inference model 1 # Inference model 1
print(evidence) print(evidence)
evidences[0] = evidence evidences[0] = evidence
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# Independent poisson process # Independent poisson process
# Inference model 2 # Inference model 2
evidences[1] = evidence evidences[1] = evidence
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# Compare evidence # Compare evidence
print(evidences) print(evidences[:2])
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# Diffuse poisson process # Diffuse poisson process
args = { args = {
'offset_mean': .5, 'offset_mean': .5,
'offset_std': (1., 1E-5), 'offset_std': (1., 1E-5),
# Amplitude of field fluctuations # Amplitude of field fluctuations
'fluctuations': (1.5, 0.5), # 1.0, 1e-2 'fluctuations': (1.5, 0.5), # 1.0, 1e-2
# Exponent of power law power spectrum component # Exponent of power law power spectrum component
'loglogavgslope': (-4., 1), # -6.0, 1 'loglogavgslope': (-4., 1), # -6.0, 1
# Amplitude of integrated Wiener process power spectrum component # Amplitude of integrated Wiener process power spectrum component
'flexibility': (1., 0.2), # 2.0, 1.0 'flexibility': (1., 0.2), # 2.0, 1.0
# How ragged the integrated Wiener process component is # How ragged the integrated Wiener process component is
'asperity': (0.1, 0.01), # 0.1, 0.5 'asperity': (0.1, 0.01), # 0.1, 0.5
# Name of the input keys # Name of the input keys
'prefix' : 'diffuse' 'prefix' : 'diffuse'
} }
correlated_field = ift.SimpleCorrelatedField(position_space, **args) correlated_field = ift.SimpleCorrelatedField(position_space, **args)
pspec = correlated_field.power_spectrum pspec = correlated_field.power_spectrum
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# Prior samples # Prior samples
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# Inference model 3 # Inference model 3
evidences[2] = evidence evidences[2] = evidence
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# Compare evidence # Compare evidence
print(evidences) print(evidences)
print(evidences - evidences[-1]) print(evidences - evidences[-1])
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Posterior visualization Posterior visualization
----------------------- -----------------------
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
plot_posterior(samples, data, model3, diffuse, model2, pspec) plot_posterior(samples, data, model3, diffuse, model2, pspec)
``` ```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment