/* Simple ASCII plot in Picat. 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. /* [[I,I*2+normal_dist(0,1)] : I in 0..10], ymax = 19.05 | * * | | | * | | | * | * | | * | * | | * | | * | | * | | |* ymin = -1.24175 x = [0,10] normal_dist_n(100,15,100) ymax = 130.516 | * * | * | | *** * * * | * * * * | * * * * ** * * * * *** | * * ** * | * * * *** * | ** * * ** ** ** * | ** * * * * | * * * ** * | * ** * * * * * |* * * * * | * * * | * * * * | ** |* * * * | * * | * | * ymin = 64.7372 x = [1,100] poisson_dist_n(5,100) ymax = 11 | * * | | * | * * * | | * * * ** * * | | * * * ** * * * * | | * ***** * ** ** * * * ** | ** * ** * ** *** ** ** | |*** ** * ** * * * * * | | ** * ** * **** | |* * * ** * ** * | * * | | * ymin = 0 x = [1,100] [[normal_dist(0,1),normal_dist(0,1)] : I in 1..300], ymax = 2.75843 | * * | | * *** | ** | * ** ** * | * ********** * | ***** ****** | *** *** *** * * | * * *** * * * |* ** ** ** ** *** * ** | ** **** ******** * | * *********** * * | * ******** ***** | ************ ***** | * *** * *** **** * | ** * * * * * | **** ******** * * | *** * | * * * | * ymin = -2.26819 x = [-3.31091,2.52605] student_t_dist_n(1,100) ymax = 8.18073 | * * |* ** * |****************************** | **** * ** * * * * * * | * * * * | | | | | * | | | * | | | * | | | | * ymin = -60.6168 x = [1,100] */ go ?=> _ = random2(), Data = [[I,I*2+normal_dist(0,1)] : I in 0..10], % Data = normal_dist_n(100,15,100), % Data = poisson_dist_n(5,100), % Data = [[normal_dist(0,1),normal_dist(0,1)] : I in 1..300], % Data = beta_dist_n(10,10,100), % Data = student_t_dist_n(1,100), show_scatter_plot(Data,30,20), nl. go => true. /* A simple model var : x Probabilities (truncated): 152.523750107627052: 0.0018867924528302 151.428362507661632: 0.0018867924528302 141.625945737004713: 0.0018867924528302 140.154017931984441: 0.0018867924528302 ......... 100.165847326595554: 0.0018867924528302 100.149752482413376: 0.0018867924528302 100.025586237857226: 0.0018867924528302 100.010134497142289: 0.0018867924528302 mean = 112.123 [len = 530,min = 100.01,mean = 112.123,median = 110.894,max = 152.524,variance = 76.064,stdev = 8.72147] Scatter plot: ymax = 152.524 | ** | | | | * * | * * | * * * | * * * * | ** * * * ** * * | ** * * ** * ** * * ** * * * | * ** * ** **** * ** **** * | ** * * ** * ** ** * * * * * * |* * * ** * * ** * ** * **** * * * * * * * * | *********** **** ** ****** * * *** ** **** * * ** ** |**** * ******* * ******* ** *** ** * ** ************** * | ***** ** ** *********** * *** ** ********* **** *** | ** * * ** *** ****** ** **** ** **** *** ** ***** * **** | * * *** **** ******** **** **** *** ***** * **** * ** |****** ***** *** * ***** ****** * ** **** *** ********* | *** ** * * * *** **** ** ** * *** * * * * * ymin = 100.01 x = [1,530] var : x >= 130 Probabilities: 0: 0.9641509433962264 1: 0.0358490566037736 mean = 0.0358491 [len = 530,min = 0,mean = 0.0358491,median = 0.0,max = 1,variance = 0.0345639,stdev = 0.185914] Scatter plot: ymax = 1 | * * * * ** * * * ** * * * * * * | | | | | | | | | | | | | | | | | | |************************************************************ ymin = 0 x = [1,530] */ go2 ?=> reset_store, run_model(1000,$model2,[show_probs_trunc,mean,show_simple_stats, show_scatter_plot,scatter_plot_size=[60,20] % show_percentiles, % show_hpd_intervals,hpd_intervals=[0.94], % show_histogram, % min_accepted_samples=1000,show_accepted_samples=true ]), nl, % show_store_lengths,nl, % fail, nl. go2 => true. model2() => X = normal_dist(100,15), P = check1(X >= 130), % Note: 0/1 for the plot observe(X >= 100), if observed_ok then add("x",X), add("x >= 130",P), end.