A question about the scope of the variable


#1

I meet some trouble about the model, if someone can give me advices, I would be grateful if anyone could give me some advice.
When I give the parameter a uniform distribution as a priori, and the likelihood under the parameter is a beta distribution, then the parameter value obtained by the model must be in the range of 0 to 1.
This is right?
Here is my code:

    alpha = 3

    with pm.Model() as test:
        beta = pm.Uniform('beta', lower=0.0, upper=1.0)
        temp1 = alpha*beta
        temp2 = alpha*(1-beta)
        obs_Y = pm.Beta('obs_Y', alpha=temp1, beta=temp2, observed=np.random.rand(100))
        trace = pm.sample(100)

#2

Yes your posterior of beta will be in the range of [0, 1]


#3

thank you for your reply!
but in a similar model,
the code is:

with pm.Model() as drawbj:
         Mu = pm.InverseGamma('Mu', alpha=Alpha, beta=Beta)
         Eta = pm.Uniform('Eta', lower=0.0, upper=1.0)
         temp1 = Mu*Eta
         temp2 = Mu*(1-Eta)
         bj = pm.Beta('bj', alpha=temp1, beta=temp2, shape=D)
         temp_a = a*bj
         temp_b = a*(1 - bj)
         obs_Y = pm.Beta('obs_Y', alpha=temp_a, beta=temp_b, observed=X)

where ‘a’ is the given parameter, I got a value greater than 1 about the posterior of bj


#4

That seems pretty unlikely - could you please share your code with data in a notebook?


#5

thank you very much!
It was previously due to the setting of a bad parameter, which has now been solved. thank you!!