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

  • Thread starter Thread starter KonstantinosS
  • Start date Start date
  • Tags Tags
    Mathematica
AI Thread Summary
To generate random numbers from specific distributions in Mathematica, the RandomVariate command is essential. However, users have encountered issues with the wrapped Cauchy and Von Mises distributions, particularly when using the ProbabilityDistribution command. One user reported an error when attempting to sample from a custom wrapped Cauchy distribution, indicating that the implementation for this distribution may not be supported. An alternative approach suggested involves generating uniform random numbers and applying the inverse of the cumulative distribution function (CDF) to obtain samples. However, challenges persist in calculating the CDF for the wrapped Cauchy distribution, with users unable to derive results through integration or standard functions. Further literature research may be necessary to find viable methods for implementing these distributions in Mathematica.
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.
 

Similar threads

Back
Top