jtobin / mwc-probability

A probability distribution type layered on top of mwc-random.
https://hackage.haskell.org/package/mwc-probability
MIT License
8 stars 7 forks source link

Add other exponential family members #1

Open jtobin opened 9 years ago

jtobin commented 9 years ago

Currently missing:

Multivariate

Matrix-valued

ocramz commented 7 years ago

In https://github.com/ocramz/sde I have implemented the symmetric Levy stable distribution, which gives the Laplace for alpha==1. Here's my code; the samples "look ok" but I haven't verified the results against known CDFs (apart from the Gaussian special case, alpha==2), so use it with caution.

alphaStable100 :: PrimMonad m => Double -> Prob m Double
alphaStable100 al = do
  u0 <- uniform
  w <- exponential 1
  let u = pi * u0 - 0.5 * pi                         -- uniform on (-pi/2, pi/2)
      t1 = sin (al * u)
      t2 = cos u**(-1/al)
      t3 = (cos ((al-1) * u) / w)**((1-al)/al)
      z = t1 * t2 * t3
  case al of 1 -> return $ tan u
             _ -> return z
jtobin commented 7 years ago

Thanks Marco, I'll take a look in a few days. Currently in Bali ringing in the new year - happy 2017! :smile:

ocramz commented 7 years ago

Here's to a smashing new year! All the best from Sweden!

ocramz commented 6 years ago

@jtobin Jared, I think the multivariate distributions need a good story for matrix algebra. Do you have any suggestions? I think adding hmatrix as a dependency here would be excessive, though. My own sparse-linear-algebra is still not ready for prime time, sadly