Sampling-importance-resampling Example: y is distributed binomial(n, p) suppose that you know that .2 < p < .4 and you place a uniform prior on this set observe 3 successes and 17 failures -- want posterior MTB > # first simulate 1000 values uniformly distributed on (.2, .4) MTB > rand 1000 c1; SUBC> unif .2 .4. MTB > # compute likelihood for each simulated value MTB > let c2=c1**3*(1-c1)**17 MTB > # convert likelihoods to probabilities MTB > let c2=c2/sum(c2) MTB > # now sample with replacement from prior sample with probabilities MTB > # proportional to the likelihoods MTB > rand 1000 c3; MTB > discrete c1 c2. ---------------------------------------------------------------------------------- Using the program 'mod_cont': MTB > name c1 'prior_s' MTB > rand 1000 'prior_s'; SUBC> unif .2 .4. MTB > exec 'mod_cont' INPUT THE NUMBER OF THE LIKELIHOOD: (1-Binomial P, 2-Normal M, 3-Poisson L, 4-Hypergeometric S, 5-Discrete Uniform N, 6-Capture/Recapture N, 7-Exponential M) DATA> 1 INPUT (number of successes, number of failures) DATA> 3 17 Input number of simulated values: DATA> 1000 : . : : .. . . ...:: . : :: . . : . : :: ::. . . . :. :: : ::::: :. .: .::::. :. :::.: ::.::: :.:::.::. :::::::::: :::::.::::::::: :::::::::::: ::::::::: .::::::::::::::::::::::::::.::::::::::::::::::::::. ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::: ---+---------+---------+---------+---------+---------+---prior_s .. : . :: : : : :: : ::::: ::.: ::::: :. .:::::::::: . ::: : :::::::::::.::::: .: .:. : : ::::::::::::::::: :::::: :. ::: : ::::::::::::::::::::::::.:::::: :.. ::::.. . :::::::::::::::::::::::::::::::.::::::::::::.::::. ---+---------+---------+---------+---------+---------+---POST_S 0.200 0.240 0.280 0.320 0.360 0.400