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

  • Mathematica
  • Thread starter KonstantinosS
  • Start date
  • Tags
    Mathematica
In summary, the conversation is about using a random number generator in Mathematica that utilizes a distribution. The command "RandomVariate" is recommended, but the user is experiencing trouble with creating a wrapped Cauchy distribution using the ProbabilityDistribution command. The conversation also discusses using the CDF function to get the CDF of the wrapped Cauchy distribution, but the user is having trouble with this as well. Further research and manual calculations may be necessary to successfully implement this distribution in Mathematica.
  • #1
KonstantinosS
6
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
  • #2
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.
 
  • #3
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,
 
  • #4
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.
 
  • #5
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,
 
  • #6
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.
 

1. What is a Random Number Generator (RNG) in Mathematica?

A Random Number Generator (RNG) in Mathematica is a function that generates a sequence of numbers that appear to be random. These numbers are not truly random, but rather follow a predetermined algorithm. RNGs are commonly used in statistical simulations, cryptography, and games.

2. What is the Wrapped Cauchy distribution in Mathematica?

The Wrapped Cauchy distribution in Mathematica is a probability distribution that models circular data. It is a circular version of the Cauchy distribution, where the values "wrap" around a circle instead of being confined to a linear range. It is commonly used in directional statistics and in modeling periodic phenomena.

3. What is the Von Mises distribution in Mathematica?

The Von Mises distribution in Mathematica is a probability distribution that also models circular data. It is a circular version of the normal distribution, with an added parameter that controls the concentration of the data around the mean. It is commonly used in directional statistics, psychometrics, and image analysis.

4. How can I generate random numbers from the Wrapped Cauchy or Von Mises distribution in Mathematica?

To generate random numbers from the Wrapped Cauchy or Von Mises distribution in Mathematica, you can use the functions RandomVariate[WrappedCauchyDistribution[μ, κ]] and RandomVariate[VonMisesDistribution[μ, κ]] respectively. These functions will generate a single random number from the specified distribution. To generate multiple random numbers, you can use the function RandomVariate[dist, n], where dist is the specified distribution and n is the number of random numbers desired.

5. Can I customize the parameters of the Wrapped Cauchy and Von Mises distributions in Mathematica?

Yes, you can customize the parameters of the Wrapped Cauchy and Von Mises distributions in Mathematica. Both distributions have two parameters: μ, the mean or location parameter, and κ, the concentration or shape parameter. You can specify these parameters when using the functions RandomVariate[WrappedCauchyDistribution[μ, κ]] and RandomVariate[VonMisesDistribution[μ, κ]]. Additionally, you can use the function PDF[dist, x] to calculate the probability density function of the distribution at a specific value x for a given set of parameters.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
408
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
257
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
2K
  • Programming and Computer Science
Replies
1
Views
635
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Programming and Computer Science
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
11
Views
499
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
Back
Top