/* Triangular distribution in Picat. From Mathematica TriangularDistribution """ An executive is given an account of historical seasonal demands for a product in millions of units. The minimum, maximum, and most likely demands are 1, 1.4, and 1.25, respectively. Find the expected demand [...] using TriangularDistribution: td = TriangularDistribution[{1, 1.4}, 1.25]; Mean[td] -> 1.21667 """ This version - with the third argument mode - is called triangular2_dist in Picat PPL. Picat> X = triangular2_dist_mean(1,1.4,1.25) X = 1.216666666666667 For more on this distribution, see ppl_distributions.pi and ppl_distributions_test.pi Cf my Gamble model gamble_.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 : d Probabilities (truncated): 1.39798860913652: 0.0001000000000000 1.397641478831406: 0.0001000000000000 1.397629226077137: 0.0001000000000000 1.39686844589101: 0.0001000000000000 ......... 1.008381621027417: 0.0001000000000000 1.007177553370896: 0.0001000000000000 1.006692846511102: 0.0001000000000000 1.006692394252017: 0.0001000000000000 mean = 1.21669 */ go ?=> reset_store, run_model(10_000,$model,[show_probs_trunc,mean % , % 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. go => true. model() => MinVal = 1, MaxVal = 1.4, Mode = 1.25, D = triangular2_dist(MinVal,MaxVal,Mode), add("d",D).