I'm trying to use pymc to solve a simple model:
I have N=1000 fluxes that I know are drawn from a Pareto distribution: flux ~ Pareto(alpha, 1)
I'm trying to work out the alpha parameter of the Pareto: alpha ~ Uniform(1, 3)
My flux measurements are contaminated by Gaussian noise: flux_meas ~ Gaussian(flux, tau)
Currently, I'm just trying to simulate what happens if I change the amount of noise.
The problem is that, when I run the model with a very small (i.e. negligible) amount of noise, the mean value of alpha changes radically for every run, and doesn't seem to be related to the true value of alpha at all. But, if I disregard the Gaussian noise entirely, and say I just observe the Pareto distribution directly, it works as expected.
What am I doing wrong?
A working code snippet is here: (A more complex, older one is here)
The key bits are as follows:
import pymc
N = 1000
true_alpha = 2
noise = 0.001 # This noise is much smaller than the signal
# Simulated fluxes
s_arr = pymc.rpareto(true_alpha, 1, size=N)
# the unknown alpha
alpha = pymc.Uniform('alpha', 1, 3)
# fluxes are drawn from a Pareto distribution
flux = pymc.Pareto('flux', alpha, 1, size=N)
# My observed fluxes are contaminated by Gaussian noise
flux_meas = pymc.Normal('flux_meas', mu=flux, tau=noise**-2, observed=True,
value=pymc.rnormal(s_arr, tau=noise**-2, size=N))
model = pymc.MCMC([alpha, flux, flux_meas])
# If I run this model several times, the mean of alpha will be somewhere between
# 1 and 3. The variance of alpha is pretty small
model.sample(5000, 1000, 5)