Questions about random number generation and the properties of numbers so generated.

learn more… | top users | synonyms (1)

14
votes
1answer
2k 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 ...
30
votes
1answer
1k 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 ...
3
votes
3answers
606 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? ...
7
votes
1answer
280 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 ...
14
votes
3answers
652 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 ...
5
votes
1answer
399 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 ...
1
vote
1answer
688 views

Add noise (random values) to data

I have a data set(x,y,z) corresponding to a hemisphere, to which I want to add some controlled noise (random values) to make the x,y,z values diverge. data = Flatten[ Table[{i, j, i^2 + j^2}, {i, ...
1
vote
1answer
336 views

Why does the mean in my coin tossing simulation not approach 1/2?

I simulate a simple experiment, a coin flip. What I do is accumulate the mean of the results up to the i-th experiment. What I can't figure out is why the computed means do not asymptotically approach ...
1
vote
1answer
160 views

Random sample with gap sizes

Lets say I have 101 instances of data with multiple attributes. In particular case, one attribute has 7 unique values. I want to get ...
8
votes
1answer
584 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 ...
14
votes
1answer
347 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: ...
30
votes
9answers
7k views

How to create animated snowfall?

Well, the title is self-explanatory. What sorts of snowfall can we generate using Mathematica? There are two options I suggest to consider: 1) Continuous GIF animations with smallest possible number ...
17
votes
1answer
436 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: ...
1
vote
1answer
107 views

Draw from HistogramDistribution with ParallelTable

I wanted to check something, but ran into troubles using HistogramDistribution in combination with ParallelTable. The code does the following: Compute a HistogramDistribution of some sample and use ...
2
votes
3answers
461 views

Small random disturbance of a flat surface

I am trying to create an initial condition which is: 1 + 0.05 rand(x,y) Here rand is a pseudorandom function distributed in the interval (-1,1). This surface ...
15
votes
3answers
667 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 ...
3
votes
2answers
290 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 ...
1
vote
3answers
194 views

How to generate new random numbers in a Manipulate only on demand?

I was playing with a Manipulateto visually compare calculating the mean of Normal and Cauchy random data. ...
11
votes
2answers
495 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
581 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 ...
11
votes
3answers
3k 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 ...
2
votes
1answer
137 views

Randomizing a lab

I teach a class where students do a weekly lab in Mathematica. They do it in a computer lab, and because there are many of them, and only one of me, I encourage them to help one another. ...
9
votes
1answer
213 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 ...
7
votes
4answers
1k 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 ...
6
votes
4answers
2k views

How to generate random directed connected graph?

How to generate random directed connected graph? I need to create graph which will pass: ConnectedGraphQ[^]
8
votes
3answers
2k 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$.
7
votes
5answers
1k 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?
25
votes
4answers
2k views

How to generate a random tree?

Is it possible to generate a random tree without explicitly constructing a random adjacency matrix that satisfies tree properties? How about a random directed tree? Edit: incredible answer by ...
14
votes
1answer
571 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 ...
2
votes
2answers
170 views

Constraining a random function

This question is a follow-up from here. I have a function that generates a list of correlations between some random variables: ...
9
votes
1answer
693 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 ...
3
votes
1answer
1k views

Creating a random normal matrix

I would like to create a random matrix with the constraint that the matrix must be normal, i.e. the matrix and its Hermitian conjugate must commute. I would create a random matrix "without ...
27
votes
2answers
2k 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 ...
1
vote
1answer
171 views

Using different random values at each recursion step

I have the following code: ϕ[0] := π/4 ϕ[n_] := Exp[-n] ϕ[n - 1] + Sqrt[1 - Exp[-2 n]] M M = RandomVariate[NormalDistribution[0, 1]] For this recursion relation, ...
3
votes
1answer
462 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 ...
2
votes
5answers
716 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 ...
6
votes
3answers
1k 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 ...
3
votes
2answers
124 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: ...
6
votes
3answers
700 views

Random Geometric Graphs

I'm trying to implement an application which uses random geometric graphs in Mathematica, but it seems Mathematica lacks the functionality. I need the following functionalities: Generate a set of ...
2
votes
3answers
572 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 ...
7
votes
1answer
889 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.
20
votes
4answers
2k 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
5answers
876 views

Picking random items out of a list only once

I'm trying to create a function that randomly returns a value from a list but remembers the values that have been given before. At the end when the list is empty it should return an empty list. ...
4
votes
2answers
260 views

Repeatedly randomly redrawing part of a random sample that matches a certain criterion

I would need some (a lot of) help to improve/rewrite some code. Since my real problem is a bit too complicated to explain, I'll try to show a simplified scheme of what I want to achieve. I create ...
17
votes
4answers
1k 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 ...
37
votes
3answers
2k views

Quality of random numbers

Mathematica has several ways of generating random numbers: Congruential, ExtendedCA, Legacy, MersenneTwister, MKL, ParallelGenerator, ParallelMersenneTwister, Rule30CA. For ...
7
votes
1answer
307 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 ...
8
votes
2answers
530 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 ...
-11
votes
4answers
443 views

Going Beyond Pseudorandom Numbers

I cooked up this simple bit of code in hopes to exceed pseudorandom number generation maybe touch the face of true randomization: ...
28
votes
1answer
2k views

RandomVariate from 2-dimensional probability distribution

A probability distribution can be created in Mathematica (I am using 8.0.1) with e.g. ...