CamDavidsonPilon / Probabilistic-Programming-and-Bayesian-Methods-for-Hackers

aka "Bayesian Methods for Hackers": An introduction to Bayesian methods + probabilistic programming with a computation/understanding-first, mathematics-second point of view. All in pure Python ;)
http://camdavidsonpilon.github.io/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/
MIT License
26.51k stars 7.84k forks source link

Ch.3|About the Categorical #444

Open leidawt opened 5 years ago

leidawt commented 5 years ago

p1 = tfd.Uniform(name='p', low=0., high=1.).sample() p2 = 1 - p1 p = tf.stack([p1, p2]) assignment = tfd.Categorical(name="assignment", probs=p)
assignment_ = evaluate(assignment.sample(sampleshape=data.shape[0], seed=42))[:10] print("prior assignment, with p = %.2f:" % evaluate(p1)) print("assigment evaluation: \n", assignment_)

I think the p1 which was printed out might not equal to the one passed to the Categorical function, because the evaluate function was executed twice, which generated different samples of p1. Am i right or wrong?