Since I'm a software engineer trying to learn more stats you'll have to forgive me before I even start, this is serious newb territory...
I've been learning PyMC and working through some really (really) simple examples. One problem I can't get to work (and can't find any related examples for) is fitting a model to data generated from two normal distributions.
Say I have 1000 values; 500 generated from a Normal(mean=100, stddev=20)
and another 500 generated from a Normal(mean=200, stddev=20)
.
If I want to fit a model to them, ie determine the two means and the single standard deviation, using PyMC. I know it's something along the lines of ...
mean1 = Uniform('mean1', lower=0.0, upper=200.0)
mean2 = Uniform('mean2', lower=0.0, upper=200.0)
precision = Gamma('precision', alpha=0.1, beta=0.1)
data = read_data_from_file_or_whatever()
@deterministic(plot=False)
def mean(m1=mean1, m2=mean2):
# but what goes here?
process = Normal('process', mu=mean, tau=precision, value=data, observed=True)
i.e., the generating process is Normal, but mu is one of two values. I just don't know how to represent the "decision" between whether a value comes from m1
or m2
.
Perhaps I'm just completely taking the wrong approach to modeling this? Can anyone point me at an example? I can read BUGS and JAGS so anything is ok really.