Hello. My first intention of writing this question was to ask about defining constraint on the priors. To explain that I made a very simple model. But I got very strange result. My model simply is y=sqrt(a-b)
and my data is defined by number 3 plus some noise. My priors are uniform distribution from 1 to 5 for both a and b. Then I expect error, because for example a=3 and b=4 makes the square root argument negative. Surprisingly I do not get any error!!! More surprisingly the results also are reasonable!!! Can someone explain me why I do not get any error, when I must have error running this code?
import pymc3 as pm import numpy as np import seaborn as sns import matplotlib.pyplot as plt np.random.seed(5) #%%our data data = 3 + np.random.normal(0,1,5) #%% defining bayesian model with pm.Model() as model: a = pm.Uniform('a',lower=1,upper=5) b = pm.Uniform('b',lower=1,upper=5) sd_lik = pm.HalfNormal('sd_lik', sd=2.0)#prior y=pm.math.sqrt(a-b) obs = pm.Normal('obs', mu=y, sd=sd_lik, observed=data) step1 = pm.Metropolis([a,b]) step2 = pm.NUTS(sd_lik) trace = pm.sample(draws=5000,tune=1000,step=[step1,step2],njobs=1,start={'a':4.5,'b':2}) #%% ppc = pm.sample_ppc(trace, model=model, samples=2000) plt.hist(ppc['obs'],30) #%% sns.set(style="white", palette="deep", color_codes=True,font_scale=4) pm.traceplot(trace, [a,b],figsize=(34,25)); pm.plots.autocorrplot(trace,figsize=(34,25)); pm.plot_posterior(trace, [sd_lik,a,b],figsize=(34,25)) #%% a_pos=trace.get_values(a) b_pos=trace.get_values(b) g = sns.jointplot(a_pos, b_pos, kind="kde", size=16, space=0) g.ax_joint.set_xlabel("a") g.ax_joint.set_ylabel("b")