Random Number Generator (RNG) in Mathematica: Wrapped Cauchy & Von Mises

  • Context: Mathematica 
  • Thread starter Thread starter KonstantinosS
  • Start date Start date
  • Tags Tags
    Mathematica
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
5 replies · 3K views
KonstantinosS
Messages
6
Reaction score
0
I'm trying to use a random number generator in Mathematica that uses a distribution. I know there's a specific command to do so but I'm a bit confused on how to use it. In my example I'm trying to get random numbers from the wrapped Cauchy and Von Mises distributions. Any help would be great.

Thanks,
 
Last edited by a moderator:
Physics news on Phys.org
Use the RandomVariate command. I don't know if Cauchy and Von Mises distributions are built in, but you can always make new distributions using the ProbabilityDistribution command. FYI, I have recently had trouble generating random numbers for hand-made multivariate distributions using ProbabilityDistribution and RandomVariate. I was able to work around it by generating a MarginalDistribution for each of my variates.
 
I used the ProbabilityDistribution for the wrapped Cauchy distribution like this:

In[1]:= WCd = ProbabilityDistribution[(1 - p^2)/(2*Pi + 2*Pi*p^2 -
4*Pi*p*Cos[x]), {x, 0, 2 Pi}, {p, 0, 1}]

but when i use the

In[2]:= RandomVariate[WCd]

i get the following error message:
RandomVariate::noimp: "Sampling from ProbabilityDistribution[(1 - p^2)/(2*Pi + 2*Pi*p^2 -
4*Pi*p*Cos[x]), {x, 0, 2 Pi}, {p, 0, 1}] is not implemented"

Any clue on what's going on?

Thanks,
 
Interesting. I have never seen that message before. RandomVariate worked for my MarginalDistribution, but then again the marginal distributions were the same as GammaDistribution and StudentTDistribution, just with different names.

You can always do a uniform real between 0 and 1 and use the inverse of the CDF of your distribution to get your random number. I had actually assumed that is what Mathematica did behind the scenes.
 
I'm trying to get the CDF of the wrapped Cauchy using the CDF function in Mathematica but in result i get absolutely nothing. I tried even integrating from -Infinity to x, but it's not working either. I'm completely stuck, any help would be appreciated.

Thanks,
 
I think you are going to have to do a literature search and find out if anyone has devised a way to implement it. I could numerically verify that the integral of the PDF was 1, but that was about it. I couldn't even evaluate the CDF numerically. I don't think that the automated routines are up to this distribution.