/* Piecewise transformation in Picat. Based on the SPPL model piecewise_transformation.pynb Cf my Gamble model gamble_piecewise_transformation.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. main => go. /* var : x Probabilities (truncated): 7.647218862214786: 0.0001000000000000 7.554555696250038: 0.0001000000000000 6.646156885333496: 0.0001000000000000 6.590823373466852: 0.0001000000000000 ......... -6.620771551812407: 0.0001000000000000 -6.929920769946673: 0.0001000000000000 -7.030719947463972: 0.0001000000000000 -7.125806862650598: 0.0001000000000000 mean = 0.00387121 HPD intervals: HPD interval (0.94): -3.81289631050185..3.69824915528616 var : z Probabilities (truncated): 369.850256969369639: 0.0001000000000000 354.782382581584272: 0.0001000000000000 339.245419342400794: 0.0001000000000000 294.328964839119351: 0.0001000000000000 ......... -4.060670527426659: 0.0001000000000000 -4.060671380795453: 0.0001000000000000 -4.060671500108283: 0.0001000000000000 -4.060672060988497: 0.0001000000000000 mean = 5.29927 HPD intervals: HPD interval (0.94): -4.06067206098850..21.93914838105016 */ go ?=> reset_store, run_model(10_000,$model,[show_probs_trunc,mean,show_hpd_intervals,hpd_intervals=[0.94]]), nl, % show_store_lengths, % fail, nl. go => true. model() => X = normal_dist(0,2), Z = cond(X < 1, pow(-X,3) + pow(X,2) + 6*X, (-5)*sqrt(X) + 11), add("x",X), add("z",Z).