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

learn more… | top users | synonyms (1)

29
votes
6answers
2k 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 ...
9
votes
3answers
2k 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 ...
25
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. ...
33
votes
5answers
2k 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. ...
16
votes
1answer
417 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: ...
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$.
18
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 ...
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?
35
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 ...
28
votes
1answer
963 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 ...
23
votes
4answers
450 views

obtaining random element of a set given by multiple inequalities

I try to obtain random elements from a set given by multiple inequalities. This is of general interest to me, but let me present one example here: I have multiple inequalities specifying half spaces ...
21
votes
3answers
588 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 ...
11
votes
2answers
459 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
1answer
474 views

Uniformly distributed n-dimensional probability vectors

What's the right way to generate a random probability vector $p={p_1,\ldots,p_n} \in {(0,1)}^n$ where $\sum_i p_i=1$, uniformly distributed over the $(n-1)$-dimensional simplex? What I have is ...
3
votes
1answer
160 views

Sample of the random times at which the random walk crosses the boundary

I defined a security boundary for a random walk: ...
2
votes
5answers
628 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 ...
14
votes
5answers
824 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. ...
1
vote
1answer
278 views

How to reject or repulse some points in a 3D cloud of particles?

I'm having an issue with a 3D distribution of points. The distribution is really nicely looking in Mathematica, but it is used in an OpenGL astronomy program (Celestia) to generate a nebula, with ...
1
vote
1answer
585 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, ...
11
votes
1answer
293 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 ...
2
votes
2answers
171 views

Expectation of a family of random variables

I did some search here, but seems that no one asked about this. I want to define a family of independent and identically distributed random variables, $x_1,...,x_n$, and then calculates the expected ...
1
vote
3answers
153 views

Number theory: Problem involving rational numbers

Use RandomRat to test whether ((-1)^(1/Denominator[q]))^Numerator[q] is identical with ...
0
votes
1answer
44 views

FindProcessParameters for Fractional Brownian Motion Returns Error

I have the following data: ...
15
votes
4answers
947 views

Finding the volume of a sphere using the Monte Carlo algorithm

I used the following code to find the volume of the sphere $x^2+y^2+z^2 = 1$ in the first octant: ...
16
votes
3answers
714 views

Generate a Random Polygon

Does some package exist with a function that takes a parameter $n$ and generates a random 2D $n$-sided simple polygon (convex or non-convex), possibly within a certain bounding box? It does not ...
6
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 ...
19
votes
2answers
725 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 ...
15
votes
1answer
253 views

Speed up adding Poisson noise to an image

I'm simulating some images corrupted with Poisson noise, but I'm encountering a few problems with performance. According to the documentation on ImageEffect, one ...
14
votes
3answers
615 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 ...
12
votes
1answer
457 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 ...
8
votes
2answers
616 views

What is the best distribution for my histogram?

I defined a security bound for a random walk (cube with 15 lengh) and i have this code to obtain a sample of the random times at which the random walk crosses the boundary for the first time: ...
8
votes
1answer
162 views

Inconsistent DistributionFitTest results?

In pondering this question, I used Mariana's function to generate the following data. ...
6
votes
2answers
98 views

Algorithm in RandomChoice[{w1,w2,…}->{e1,e2,…},n]?

I wonder if someone happens to know the actual algorithm implemented in the particular overload of RandomChoice that handles explicitly presented discrete ...
16
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 ...
8
votes
2answers
497 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 ...
6
votes
3answers
468 views

How to randomly erode a 3D distribution of points with Mma 7.0?

Suppose we have a 3D distribution of points, like the spherical ball example below : ...
5
votes
1answer
136 views

Computing the Hurst exponent or fractal dimension of fractional Brownian motion

The Hurst exponent is related to the fractal dimension by noticing that the fractal dimension $D$ is equal to $2-H$, where $d$ is the intrinsic dimension and $H$ is the Hurst exponent, for 1-D ...
5
votes
2answers
671 views

Random walk on a sphere [closed]

I'm trying to programme a random walk on a sphere with Mathematica. I found this code while I was searching, but I'm not getting results from it. I waited an entire day, but my pc didn't finish ...
3
votes
3answers
543 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? ...
10
votes
2answers
540 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
4answers
354 views

Why is Poisson Random Deviate Generation so slow?

I am generating Poisson deviates for some numerical work. Mathematica 9.0.1 is very slow in generating these random numbers, as can be seen below. ...
9
votes
1answer
651 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 ...
4
votes
4answers
559 views

Skip other If conditions

I'm trying to write a code to "random" move in a matrix but it can't go to a certain position if it has a certain value (in this case I'm using the number 2). How do I make it to skip all other If ...
4
votes
1answer
135 views

How do I randomly select 'k' positions in a list and shuffle their respective elements without effecting the other elements?

Imagine I have some list: listA = {"a","b","c","d","e","f","g","h","i","j"}; I'd like to randomly select k positions in the ...
3
votes
1answer
135 views

Simulating a bounded continuous random walk in $n$-dimensions

You're given three $n$-dimensional real vectors, $\mathbf{x_0}$, $\mathbf{a}$ and $\mathbf{b}$, with $\mathbf{a} \le \mathbf{x_0} \le \mathbf{b}$ (vector inequality means component-wise inequality). ...
3
votes
1answer
405 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
3answers
123 views

Performance on Multinomial Deviate is slow

Most of the time in my program is spent on this single line of code: out = RandomVariate[MultinomialDistribution[nt, tmp]]; ...
2
votes
1answer
215 views

SDE boundary condition

I have a simple SDE with white noise: ...
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. ...
1
vote
3answers
117 views

Random reals according to conditions

I'd like to create a list of triplets $(x,y,z)$ which satisfy the following properties: $$0<x<1/2 \\ 0<y<1/2-x \\ -1<z<-2(x+y)$$ Basically I would like to uniformly generate random ...