Distributions.jl : generating samples from stable distributions

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Distributions.jl : generating samples from stable distributions

Mirmu
I am looking for generating samples from the stable Levy family with Distributions.jl, but I cannot find it.
https://en.wikipedia.org/wiki/Stable_distribution

Did I miss it, or there is a reason why it is not yet implemented ?

Best
Reply | Threaded
Open this post in threaded view
|

Re: Distributions.jl : generating samples from stable distributions

John Myles White
This is extremely difficult to do right, which is why we don't support it yet.

--John

On Friday, August 19, 2016 at 9:26:19 AM UTC-7, Mirmu wrote:
I am looking for generating samples from the stable Levy family with Distributions.jl, but I cannot find it.
<a href="https://en.wikipedia.org/wiki/Stable_distribution" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fen.wikipedia.org%2Fwiki%2FStable_distribution\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGppOLHljg0fVP-X1mRD1cNBdOkfw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fen.wikipedia.org%2Fwiki%2FStable_distribution\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGppOLHljg0fVP-X1mRD1cNBdOkfw&#39;;return true;">https://en.wikipedia.org/wiki/Stable_distribution

Did I miss it, or there is a reason why it is not yet implemented ?

Best
Reply | Threaded
Open this post in threaded view
|

Re: Distributions.jl : generating samples from stable distributions

Rock Pereira
In reply to this post by Mirmu
It's available in R. Look up the package 'stabledist'. It has function
 rstable(n, alpha, beta, gamma, delta, pm)

Stable distributions are difficult to generate because the pdf does not have a closed form.
For the Levy distribution, alpha=0.5, beta=1.
I wanted to do the generation in R, and the MLE optimization in Julia, but didn't get round to it.


Reply | Threaded
Open this post in threaded view
|

Re: Distributions.jl : generating samples from stable distributions

John Myles White
Unfortunately the R package is GPL, so we can't use it as a template for a Julia implementation. But RCall will let you call that package from Julia to get draws from those distributions, so you should be able to do what you suggested pretty easily.

--John

On Friday, August 19, 2016 at 1:44:06 PM UTC-7, Rock Pereira wrote:
It's available in R. Look up the package 'stabledist'. It has function
 rstable(n, alpha, beta, gamma, delta, pm)

Stable distributions are difficult to generate because the pdf does not have a closed form.
For the Levy distribution, alpha=0.5, beta=1.
I was trying to answer a question on StackOverflow <a href="http://stackoverflow.com/questions/38774913/fbasicsfitstable-working-suspiciously" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F38774913%2Ffbasicsfitstable-working-suspiciously\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE-RQ-KstDXECYKespNMwShQzj63w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F38774913%2Ffbasicsfitstable-working-suspiciously\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE-RQ-KstDXECYKespNMwShQzj63w&#39;;return true;">http://stackoverflow.com/questions/38774913/fbasicsfitstable-working-suspiciously
I wanted to do the generation in R, and the MLE optimization in Julia, but didn't get round to it.


Reply | Threaded
Open this post in threaded view
|

Re: Distributions.jl : generating samples from stable distributions

Mirmu
Ok, after a glance at the literature, I understand those distributions are quite tricky to sample from.
Using RCall might be a bit overkill.
Maybe
http://prac.im.pwr.wroc.pl/~hugo/publ/AWeronRWeron95_LNP.pdf
would be an easy (if slow) way ? (although I am not a statistician so I cannot judge its accuracy). I could give it a shot for the package if you feel it's worthy

Best
Reply | Threaded
Open this post in threaded view
|

Re: Distributions.jl : generating samples from stable distributions

Rock Pereira
In reply to this post by Mirmu
RCall is a simple two-step process:
  1. Write the R script inside Julia's R macrostrings
  2. Copy the objects in R as objects in Julia

R has a massive collection in its Distributions Task View http://lib.stat.cmu.edu/R/CRAN/web/views/Distributions.html
Search (press F3) for 'stable' to find other packages.

If you're dealing only with draws from the Levy distribution (and not the whole family of stable distributions) 

using Distributions
x
= rand(Levy(u, c), numSamples)
Reply | Threaded
Open this post in threaded view
|

Re: Distributions.jl : generating samples from stable distributions

Mirmu
Thx a lot !



Le lundi 22 août 2016 23:19:11 UTC+2, Rock Pereira a écrit :
RCall is a simple two-step process:
  1. Write the R script inside Julia's R macrostrings
  2. Copy the objects in R as objects in Julia
The documentation is just one page. <a href="http://juliastats.github.io/RCall.jl/latest/gettingstarted/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjuliastats.github.io%2FRCall.jl%2Flatest%2Fgettingstarted%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHqjs_Uv-YMTxJKqDX2i3GP1Sj_Vw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjuliastats.github.io%2FRCall.jl%2Flatest%2Fgettingstarted%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHqjs_Uv-YMTxJKqDX2i3GP1Sj_Vw&#39;;return true;">http://juliastats.github.io/RCall.jl/latest/gettingstarted/

R has a massive collection in its Distributions Task View <a href="http://lib.stat.cmu.edu/R/CRAN/web/views/Distributions.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Flib.stat.cmu.edu%2FR%2FCRAN%2Fweb%2Fviews%2FDistributions.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG2xmo57L4oC-WvMZL5V7bQCM-wlQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Flib.stat.cmu.edu%2FR%2FCRAN%2Fweb%2Fviews%2FDistributions.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG2xmo57L4oC-WvMZL5V7bQCM-wlQ&#39;;return true;">http://lib.stat.cmu.edu/R/CRAN/web/views/Distributions.html
Search (press F3) for 'stable' to find other packages.

If you're dealing only with draws from the Levy distribution (and not the whole family of stable distributions) 
you can do it in Julia: <a href="http://distributionsjl.readthedocs.io/en/latest/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdistributionsjl.readthedocs.io%2Fen%2Flatest%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF0udIkxO40pL3sjIURdpWLKUTtJA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdistributionsjl.readthedocs.io%2Fen%2Flatest%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF0udIkxO40pL3sjIURdpWLKUTtJA&#39;;return true;">http://distributionsjl.readthedocs.io/en/latest/

using Distributions
x
= rand(Levy(u, c), numSamples)