/* Logistic distribution in Picat. From https://en.wikipedia.org/wiki/Logistic_distribution """ Quantile function The inverse cumulative distribution function (quantile function) of the logistic distribution is a generalization of the logit function. Its derivative is called the quantile density function. They are defined as follows: Q(p;mu,s) = mu + s * ln(p/(1-p)) Q(p;s) = s/(p*(1-p)) """ See ppl_distributions.pi and ppl_distributions_test.pi for more on this Picat> X = logistic_dist_mean() X = 0 Picat> X = logistic_dist_mean(3,1) X = 3 Cf my Gamble model gamble_logistic_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 : d01 Probabilities (truncated): 9.599250788206096: 0.0001000000000000 8.602802133450959: 0.0001000000000000 7.836383680564602: 0.0001000000000000 7.471575902150391: 0.0001000000000000 ......... -8.189390621598006: 0.0001000000000000 -8.262416218626065: 0.0001000000000000 -8.781663274976005: 0.0001000000000000 -9.024356082459152: 0.0001000000000000 mean = -0.00307931 Histogram (total 10000) -9.024: 1 (0.000 / 0.000) -8.559: 1 (0.000 / 0.000) -8.093: 2 (0.000 / 0.000) -7.628: 5 (0.001 / 0.001) -7.162: 2 (0.000 / 0.001) -6.696: 4 (0.000 / 0.002) -6.231: 14 # (0.001 / 0.003) -5.765: 19 # (0.002 / 0.005) -5.300: 22 # (0.002 / 0.007) -4.834: 31 ## (0.003 / 0.010) -4.368: 72 #### (0.007 / 0.017) -3.903: 94 ##### (0.009 / 0.027) -3.437: 151 ######## (0.015 / 0.042) -2.972: 213 ########### (0.021 / 0.063) -2.506: 317 ################# (0.032 / 0.095) -2.041: 482 ######################### (0.048 / 0.143) -1.575: 655 ################################## (0.066 / 0.208) -1.109: 912 ################################################ (0.091 / 0.300) -0.644: 1047 ####################################################### (0.105 / 0.404) -0.178: 1152 ############################################################ (0.115 / 0.520) 0.287: 1109 ########################################################## (0.111 / 0.630) 0.753: 947 ################################################# (0.095 / 0.725) 1.219: 804 ########################################## (0.080 / 0.806) 1.684: 611 ################################ (0.061 / 0.867) 2.150: 449 ####################### (0.045 / 0.912) 2.615: 322 ################# (0.032 / 0.944) 3.081: 187 ########## (0.019 / 0.963) 3.547: 123 ###### (0.012 / 0.975) 4.012: 89 ##### (0.009 / 0.984) 4.478: 55 ### (0.005 / 0.989) 4.943: 46 ## (0.005 / 0.994) 5.409: 22 # (0.002 / 0.996) 5.875: 19 # (0.002 / 0.998) 6.340: 8 (0.001 / 0.999) 6.806: 3 (0.000 / 0.999) 7.271: 7 (0.001 / 1.000) 7.737: 1 (0.000 / 1.000) 8.202: 0 (0.000 / 1.000) 8.668: 1 (0.000 / 1.000) 9.134: 1 (0.000 / 1.000) kurtosis_excess_unbiased(10000,34083.0,473680.0) Summary statistics Count: 10000 Min: -9.0243560824591516 Max: 9.5992507882060956 Sum: -30.793103589103595 Mean: -0.0030793103589104647 Variance (pop): 3.4083030910553158 Std dev (pop): 1.8461590102305152 Variance (sample): 3.4086439554508607 Std dev (sample): 1.8462513251046999 Skewness (unbiased): 0.000116920509148647 Kurtosis excess: -3.0004923325443875 Median: -0.016754860994244503 Q1 (25%): -1.1172540612742756 Q3 (75%): 1.1186821414835033 var : d Probabilities (truncated): 14.190618108480505: 0.0001000000000000 12.44963168232429: 0.0001000000000000 11.600197140137251: 0.0001000000000000 11.301566078694258: 0.0001000000000000 ......... -4.824490588013136: 0.0001000000000000 -4.895694320474348: 0.0001000000000000 -6.403668392260215: 0.0001000000000000 -6.413880324957223: 0.0001000000000000 mean = 3.01323 Histogram (total 10000) -6.414: 2 (0.000 / 0.000) -5.899: 0 (0.000 / 0.000) -5.384: 0 (0.000 / 0.000) -4.869: 4 (0.000 / 0.001) -4.353: 1 (0.000 / 0.001) -3.838: 9 (0.001 / 0.002) -3.323: 7 (0.001 / 0.002) -2.808: 19 # (0.002 / 0.004) -2.293: 17 # (0.002 / 0.006) -1.778: 55 ### (0.005 / 0.011) -1.263: 64 ### (0.006 / 0.018) -0.748: 110 ##### (0.011 / 0.029) -0.233: 205 ########## (0.021 / 0.049) 0.283: 303 ############## (0.030 / 0.080) 0.798: 456 ###################### (0.046 / 0.125) 1.313: 674 ################################ (0.067 / 0.193) 1.828: 976 ############################################### (0.098 / 0.290) 2.343: 1177 ######################################################## (0.118 / 0.408) 2.858: 1256 ############################################################ (0.126 / 0.534) 3.373: 1172 ######################################################## (0.117 / 0.651) 3.888: 1001 ################################################ (0.100 / 0.751) 4.403: 828 ######################################## (0.083 / 0.834) 4.919: 597 ############################# (0.060 / 0.893) 5.434: 392 ################### (0.039 / 0.932) 5.949: 241 ############ (0.024 / 0.957) 6.464: 172 ######## (0.017 / 0.974) 6.979: 101 ##### (0.010 / 0.984) 7.494: 56 ### (0.006 / 0.990) 8.009: 46 ## (0.005 / 0.994) 8.524: 19 # (0.002 / 0.996) 9.039: 17 # (0.002 / 0.998) 9.555: 10 (0.001 / 0.999) 10.070: 4 (0.000 / 0.999) 10.585: 3 (0.000 / 0.999) 11.100: 3 (0.000 / 1.000) 11.615: 1 (0.000 / 1.000) 12.130: 0 (0.000 / 1.000) 12.645: 1 (0.000 / 1.000) 13.160: 0 (0.000 / 1.000) 13.676: 1 (0.000 / 1.000) kurtosis_excess_unbiased(10000,34101.0,489450.0) Summary statistics Count: 10000 Min: -6.4138803249572227 Max: 14.190618108480505 Sum: 30132.255796140507 Mean: 3.0132255796140637 Variance (pop): 3.4100975103138591 Std dev (pop): 1.8466449334709309 Variance (sample): 3.4104385541692759 Std dev (sample): 1.8467372726431002 Skewness (unbiased): 0.00069905764496645156 Kurtosis excess: -3.000479193985631 Median: 2.9841192703828798 Q1 (25%): 1.9030132024816835 Q3 (75%): 4.1434060287300216 */ go ?=> reset_store, run_model(10_000,$model,[show_probs_trunc,mean, % show_percentiles, % show_hpd_intervals,hpd_intervals=[0.94], show_histogram, show_stats % min_accepted_samples=1000,show_accepted_samples=true ]), nl, % show_store_lengths,nl, % fail, nl. go => true. model() => Mu = 3, S = 1, D01 = logistic_dist(), D = logistic_dist(Mu,S), add("d01",D01), add("d",D).