Hi all,
I have two kinds of data: a vector of counts
and a vector of ENERGIES
. The counts
vector has the shape of a sum of gaussians when plotted vs. its indices:
counts[x] = sum(somegaussians[x])
and I expect the ENERGIES
to be a linear function of the means of the gaussians:
ENERGIES = intecept + slope * mu
I add my code below. I’d like to know how to incorporate the very low uncertainty in the energies (sigma inside energy_obs) without the Markov Chain failing:
DATA_BINS = 4096
ENERGIES = [5.34036, 5.42315, 5.68537, 6.05078, 6.28808, 6.7783, 8.78486] # MeV
THRESHOLD = 5
N = 7
# read data from file:
datafile = 'Alpha_Radiation/cumulated_histogram.txt'
counts = read_data.read_data_file(datafile, (0, DATA_BINS))
bins = np.linspace(1/2, DATA_BINS+1/2, DATA_BINS)
# Clear data:
indices = np.where((THRESHOLD < counts) & (2722 < bins) & (bins < 2800))
counts = counts[indices]
bins = bins[indices]
mod_seven_gaussians = pm.Model()
with mod_seven_gaussians:
# priors
amp = pm.Uniform('amp', amp_est_mean-50, amp_est_mean+50.0, shape=N)
mu = pm.Uniform('mu', mu_est_mean-50, mu_est_mean+50.0, shape=N)
sig = pm.Uniform('sig', sig_est_mean-7, sig_est_mean+8, shape=N)
intercept = pm.Uniform('intercept', intecept_est_mean-1, intecept_est_mean+1)
slope = pm.Uniform('slope', slope_est_mean-1e-2, slope_est_mean+1e-2)
# likelihood
counts_obs = pm.Normal('counts',
mu=(amp[0]*np.exp(-(bins-mu[0])**2 / sig[0]**2)
+ amp[1]*np.exp(-(bins-mu[1])**2 / sig[1]**2)
+ amp[2]*np.exp(-(bins-mu[2])**2 / sig[2]**2)
+ amp[3]*np.exp(-(bins-mu[3])**2 / sig[3]**2)
+ amp[4]*np.exp(-(bins-mu[4])**2 / sig[4]**2)
+ amp[5]*np.exp(-(bins-mu[5])**2 / sig[5]**2)
+ amp[6]*np.exp(-(bins-mu[6])**2 / sig[6]**2)
),
sigma=np.sqrt(counts),
observed=counts)
energy_obs = pm.Normal('energies',
mu=intercept + slope*mu,
sigma=1e-6,
observed=ENERGIES)
trace = pm.sample(20000, return_inferencedata=False)
Thanks a lot,
Inbar