/* Chi squared dist (generating samples) in Picat. From Handbook on probability distributions page 75ff See ppl_distributions.pi for the definitions of PDF, CDF, and quantile, and ppl_distributions_test.pi for tests of these. Cf my Gamble model gamble_chi_squared_dist.rkt This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import ppl_distributions, ppl_utils. import util. % import ordset. main => go. /* var : g Probabilities (truncated): 23.220378886476862: 0.0001000000000000 23.112031369404924: 0.0001000000000000 21.312284799449049: 0.0001000000000000 21.040649689853446: 0.0001000000000000 ......... 0.037084654771348: 0.0001000000000000 0.033025682418936: 0.0001000000000000 0.032543769112855: 0.0001000000000000 0.024271771550639: 0.0001000000000000 mean = 4.00127 var : mean theoretical Probabilities: 4: 1.0000000000000000 mean = 4.0 */ go ?=> reset_store, run_model(10_000,$model,[show_probs_trunc,mean]), nl, % show_store_lengths,nl, % fail, nl. go => true. model() => K = 4, G = chi_square_dist(K), Mean = chi_square_dist_mean(K), add("g",G), add("mean theoretical",Mean).