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

  • Context: Mathematica 
  • Thread starter Thread starter KonstantinosS
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary

Discussion Overview

The discussion centers around the implementation of random number generators in Mathematica, specifically focusing on the wrapped Cauchy and Von Mises distributions. Participants explore commands and methods for generating random numbers from these distributions, addressing both theoretical and practical challenges encountered in the process.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant seeks assistance with using a random number generator in Mathematica for wrapped Cauchy and Von Mises distributions.
  • Another participant suggests using the RandomVariate command and mentions the possibility of creating custom distributions with ProbabilityDistribution, sharing their own challenges with multivariate distributions.
  • A participant provides an example of using ProbabilityDistribution for the wrapped Cauchy distribution but encounters an error when attempting to use RandomVariate, indicating that sampling from their defined distribution is not implemented.
  • Another participant notes they have not seen the error message before and shares their success with MarginalDistribution, suggesting an alternative method using the inverse of the CDF for generating random numbers.
  • One participant expresses difficulty in obtaining the CDF of the wrapped Cauchy distribution, reporting that attempts to integrate yield no results.
  • A later reply suggests conducting a literature search for existing implementations and mentions the inability to evaluate the CDF numerically, indicating potential limitations in Mathematica's automated routines for this distribution.

Areas of Agreement / Disagreement

Participants express various challenges and uncertainties regarding the implementation of random number generation for the wrapped Cauchy and Von Mises distributions. There is no consensus on a definitive solution, and multiple competing views and methods are presented.

Contextual Notes

Limitations include unresolved issues with the implementation of the wrapped Cauchy distribution in Mathematica, particularly regarding the sampling and evaluation of the CDF. Participants highlight the need for further exploration and validation of methods.

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

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
8K