viz.fun 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #import std
  2. #import nat
  3. #import flo
  4. #import plo
  5. #import ren
  6. ---------------------------- constants --------------------------------
  7. imean = 100. # mean at time 0
  8. sigma = 0.3 # larger numbers make the variance increase faster
  9. mu = 0.6 # larger numbers make the mean drift upward faster
  10. ------------------------ functions of time ----------------------------
  11. expectation = times/imean+ exp+ times/mu
  12. theta = minus^(ln+ ~&l,div\2.+ ln+ plus)^/sqr+expectation marv
  13. lambda = sqrt+ ln+ plus/1.+ div^/marv sqr+ expectation
  14. marv = # variance of the marginal distribution
  15. times/sqr(imean)+ times^(
  16. exp+ times/2.+ times/mu,
  17. minus\1.+ exp+ //times sqr sigma)
  18. rho = # takes a positive time value to a probability density function
  19. "t". 0.?=/0.! "x". div(
  20. exp negative div\2. sqr div(minus/ln"x" theta "t",lambda "t"),
  21. times/sqrt(times/2. pi) times/lambda"t" "x")
  22. ------------------------- image specifications -----------------------
  23. #binary+
  24. #output dot'tex' //rendering ('ihn+',1.5,1.)
  25. spread =
  26. visualization[
  27. margin: 35.,
  28. headroom: 25.,
  29. picture_frame: ((350.,350.),(-15.,-25.)),
  30. pegaxis: axis[variable: '\textsl{time}'],
  31. abscissa: axis[variable: '\textsl{estimate}'],
  32. ordinates: <
  33. axis[variable: '$\rho$',hatches: ari5/0. .04,alias: (10.,0.)]>,
  34. curves: ~&H(
  35. * curve$[peg: ~&hr,points: * ^/~&l ^H\~&l rho+ ~&r],
  36. |=&r ~&K0 (ari41/75. 175.,ari31/0.1 .6))]