Questions about random number generation and the properties of numbers so generated.
28
votes
4answers
777 views
Quality of random numbers
Mathematica has several ways of generating random numbers: Congruential, ExtendedCA, Legacy, MersenneTwister, MKL, ParallelGenerator, ParallelMersenneTwister, Rule30CA.
For ...
27
votes
5answers
992 views
Distribution of random points in 3D space to simulate the Crab Nebula
I'm generating some 3D models of planetary nebulae and supernova remnants for Celestia, a free OpenGL astronomy software.
Currently, I know how to do it with random points inside a spherical shell. ...
25
votes
2answers
1k views
Efficient Langevin Equation Solver
This question is not about good algorithms for solving stochastic differential equations. It is about how to implement simple codes in Mathematica efficiently exploiting Mathematica's programming ...
23
votes
1answer
371 views
Finding the likeliest path in a Markov process
With Mathematica 9, we have the addition of various processes, among which the discrete Markov process. Given a transition probability matrix m, such a process is ...
20
votes
1answer
716 views
RandomVariate from 2-dimensional probability distribution
A probability distribution can be created in Mathematica (I am using 8.0.1) with e.g.
...
17
votes
1answer
287 views
Efficient Generation of Random Variates from a Copula Distribution
I have a 7-asset portfolio for which I want to simulate daily log-deltas using a Student T copula. The marginal distributions are all either Stable or TsallisQGaussian. Using NMaximize, I have ...
16
votes
6answers
991 views
Efficient way to generate random points with a predefined lower bound on their pairwise Euclidean distance
Using Mathematica what is an efficient way to generate a list of $n$ random two dimensional points $\{x_i,y_i\}$ where $i=1,...,n$ so that no two points $p_1$ and $p_2$ in the list has an Euclidean ...
15
votes
4answers
741 views
Random data generator
Inspired by Quality of random numbers I would like to set up a true random data generator in Mathematica.
My idea is to use the static from an open microphone. I recall reading about extracting the ...
15
votes
1answer
477 views
Mathematica giving infinity as a random number!
I am trying to generate several random numbers from normal distribution using Mathematica. The following is the relevant code:
...
14
votes
4answers
878 views
Efficiently generating n-D Gaussian random fields
I am interested in an efficient code to generate an $n$-D Gaussian random field (sometimes called processes in other fields of research), which has applications in cosmology. I wrote the following ...
14
votes
1answer
254 views
Simulating Theatre puzzle
I have been trying to simulate the process of the theatre puzzle from the Joy of X (Strogatz).
The puzzle, and some relevant material are here.
My simplistic coding for this process follows:
...
13
votes
3answers
283 views
Plotting the solution of a vector stochastic differential equation
I have a vector stochastic differential equation,
$$\mathrm dq = p\,\mathrm dt\qquad q(0)=0$$
$$\mathrm dp = (-q -p)\mathrm dt+\mathrm dW\qquad p(0)=10$$
This can be entered to give me the process ...
13
votes
1answer
288 views
RandomVariate returns values outside the support of a PDF
Let $X$ be a random variable with pdf:
dist = ProbabilityDistribution[1/(Abs[x]*Log[Abs[x]]^2), {x, -E^-2, E^-2}]
Here are some pseudo-random drawings from it:
...
12
votes
1answer
417 views
Compare C++ Standard Library's Mersenne Twister with Mathematica's Mersenne Twister
The C++ standard library does contain a set of random distribution classes, among other things a Mersenne Twister engine.
What I'd like to do is to generate the same random number distribution, using ...
11
votes
1answer
322 views
Simulating Stochastic Processes the MMA way
This question is really a specific problem and a methodological one concerning MMA best practices. I want to simulate a system of stochastic processes. If this were a geometric Brownian motion or ...
11
votes
1answer
225 views
Are there rules of thumb for knowing when RandomVariate is more efficient than RandomReal?
Please consider the following:
From a fresh Mathematica kernel, RandomVariate is more efficient for NormalDistribution but ...
11
votes
1answer
289 views
Which Distributions can be Compiled using RandomVariate
Recently, Oleksandr kindly showed a list of Mathematica commands that can be compiled.
RandomVariate was part of that list. However, whether this can be compiled depends upon the distribution that is ...
10
votes
3answers
376 views
1D Random Walk variant
I am making a notebook that is a variation to the traditional 1d random walk problem.
The normal 1D random walk can be simulated easily by
...
10
votes
3answers
239 views
Efficient implementation of a linear complexity measure of binary sequences
For a implementation of testing the quality of random number generators I implemented the NIST test suite in Mathematica based on the nice workbook by Ilja Gerhardt.
However I took up the challenge ...
10
votes
1answer
179 views
Simulating discrete time stochastic dynamic systems
What is the canonical way of simulating discrete time stochastic dynamical systems in Mathematica using the new functionality of Random processes?
To take a concrete example, lets consider the ...
9
votes
2answers
265 views
Fast Simulations with Compile
this post relates to another post that I didn't follow up propely. If I wanted to simulate
a system of stochastic proesses like the following, and loop over this run many many times
would writing the ...
9
votes
2answers
390 views
Creating randomly oriented planes
I would like to create randomly oriented planes.
This is how I'm attempting to do that:
I create a 2 random unit vectors, $\mathbf{v}_1$, and $\mathbf{v}_2$, in the $x$-$y$ plane
I assume that if I ...
9
votes
1answer
308 views
Functional programming and Do loops
I'm writing a Monte Carlo simulation. I'm using a Do loop to create the different simulations, iterating over different ...
9
votes
1answer
150 views
RandomReal closed on left & open on right?
I have a number of algorithms that depend on uniform random reals in half-open intervals such as $[0,1)$. In particular, I need a (pseudo) random-number generator that produces machine-precision ...
8
votes
3answers
628 views
How to generate a RandomVariate of a custom distribution?
I'm trying to generate a pseudorandom variate out of a custom distribution. Suppose I want define a custom distribution, and for the sake of simplicity I define a Poisson distribution (the ...
8
votes
2answers
330 views
Fluorescence Correlation Spectroscopy Simulation
I am simulating Fluorescence Correlation Spectroscopy which basically involves tracking the random motion of particles in a box with periodic boundary conditions and then calculating their intensity ...
8
votes
2answers
319 views
Most efficient way to obtain samples from high-dimensional multivariate distributions?
Is MultinormalDistribution[] efficient and easy to use for high dimensions?
I have a variable $n$ representing the dimension of a Monte Carlo integration I do on a ...
8
votes
1answer
334 views
Recommended book on random processes to understand new functionality in Mathematica 9?
I am interested in exploring the new functionality on random processes available in Mathematica 9, but I am not familiar with all of the underlying mathematics.
Could you recommend a book that ...
7
votes
1answer
598 views
Wald–Wolfowitz Runs Test
Does Mathematica 8 implement Wald–Wolfowitz runs test for randomness? I can't find it in the documentation. I would like to test some fit residuals.
7
votes
1answer
216 views
RandomVariate with a Discrete Distribution
Nature has provided me with a random variable $Z$ taking on the values $0, 1, 2, \ldots$, with probabilities $z_0, z_1, \cdots$. I can sample from the distribution of $Z$ reasonably efficiently (I ...
6
votes
3answers
574 views
Generating unique random number lists
I am new in programming. I have an array containing, let's say 20 elements and first I want to randomly select two elements from it and record them. Then I will select two elements from the array of ...
6
votes
3answers
226 views
A deterministic function to generate a random number
Using Mathematica, I need to define a function of one integer variable that generates the same real number in the range 0 to 1, if it is called with the same argument, but gives a different real ...
6
votes
3answers
678 views
Randomly packing spheres of fixed radius within a cube
How can I have Mathematica randomly place spheres in a cube so they won't overlap? The cube is $20 \times 20 \times 20$, and the spheres have a radius of $0.7$.
6
votes
1answer
189 views
1D Random Walk with Excluded Sites and Variable Time-Step
Here is the physical problem I would like to simulate:
Consider the following variations to the 1d random walk:
allow for certain, random sites to be excluded with probability 1/2.
allow for the ...
5
votes
4answers
491 views
3D Random Walk with Periodic Boundary Conditions
I am working on a 3D random walk with periodic boundary conditions and have written a program that will do this for me but it is extremely slow. Does anyone have any suggestions on how I could speed ...
5
votes
4answers
440 views
How to generate random directed connected graph?
How to generate random directed connected graph?
I need to create graph which will pass:
ConnectedGraphQ[^]
5
votes
1answer
128 views
Random number generation with specific distribution
I am writing a program for solving the shortest path in travelling salesman problem, with a twist that there are multiple salesmen who partition the cities among themselves, thus creating two part ...
4
votes
5answers
445 views
Vectors with a certain magnitude in Mathematica
For a user specified magnitude, is there a way to have Mathematica produce any 3D vector that fits that magnitude?
4
votes
1answer
230 views
How to fix errors in Gram-Schmidt process when using random vectors?
I first make a function to get a random vector on unit sphere in a swath around the equator. That is what the parameter $\gamma$ controls; if $\gamma = 1/2$, the vectors can be chosen anywhere on the ...
3
votes
2answers
574 views
creating vectors with normal distribution of lengths
First consider vectors of unit length, say on the unit sphere.
Now I want to give some magnitude to these vectors and I want the magnitude to be chosen from the normal distribution.
In one dimension ...
3
votes
1answer
144 views
White noise $\eta(t)$
How to make a random function $\eta(t)$ to insert in a differential equation for NDSolve?
Edit: example: to solve equations like $\frac{dx}{dt}=\eta(t)$
3
votes
2answers
142 views
Colors associated to parts of a 3D distribution of points
Suppose we have a long list of random points (cartesian coordinates) in 3D space.
coords := ...;
Until now, I was associating colors in a radial way, from the ...
3
votes
3answers
262 views
Generating a random walk with defined step size
By the following I'm trying to generate a list of random coordinates (ex. 4) each within unit distance from previous one, starting from origin. What am I doing wrong?
...
3
votes
2answers
96 views
Why do I keep getting 0.06 with WorkingPrecision->1?
I'm trying to generate a list of 1000 random numbers with WorkingPrecision->1. Is there any particular reason that I'm getting some entries as 0.06?
I have tested the following lines:
...
3
votes
1answer
129 views
Generate a new output using Manipulate
Thanks to methods found in the below, I was able to assemble those elements :
Tile image on specific location without space between them
How to combine images with the same dimensions in a grid?
...
2
votes
5answers
265 views
Assigning a particular value to array elements
I have an array of 10000 elements. I want to randomly assign energy to these 10000 elements using Gaussian or Exponential distribution, such that each time a particular element is selected its energy ...
2
votes
2answers
132 views
Illustrating half life
I'm teaching some lessons on negative exponents and one application listed was half life since the rate of decay can be written as 2^-1 every __ years.
I found this nice animation on the net.
...
2
votes
3answers
414 views
Some questions about random numbers
How can I get non-repeating random numbers from Mathematica 8?
How can I know which distribution the numbers I get are?
Can I choose the distribution I want together with the non-repeating random ...
2
votes
2answers
168 views
Generating a range of numbers according to some rules
I'm pretty new to Mathematica, and I'm mainly a programmer so I don't have a lot of knowledge about maths.
I want to generate a set of UNIQUE incremental numbers (series) according to the following ...
2
votes
1answer
209 views
Randomly selecting elements without repetition
I assigned energy values to each element in the array as per the program of Verbeia. The program looks like this
...


