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

learn more… | top users | synonyms (1)

37
votes
7answers
4k 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 ...
32
votes
1answer
3k views

RandomVariate from 2-dimensional probability distribution

A probability distribution can be created in Mathematica (I am using 8.0.1) with e.g. ...
27
votes
3answers
1k 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 ...
15
votes
1answer
1k views

Uniformly distributed n-dimensional probability vectors over a simplex

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 ...
32
votes
5answers
816 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 ...
34
votes
8answers
2k views

How to generate random points in a region?

The Mathematica 10 documentation was updated for FindInstance adding support for regions. In my use case, I'm trying to sample points in a set of disks: ...
32
votes
9answers
11k 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 ...
23
votes
4answers
3k 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. Attempt I wrote the ...
7
votes
6answers
2k views

Vectors with a certain magnitude in Mathematica

For a user-specified magnitude, is there a way to have Mathematica produce any 3D vector with that magnitude?
31
votes
5answers
3k views

2D random walk within a bounded area

I want to simulate a random walk on two dimension in a bounded area such as a square or circle. I am thinking of using If statement to define a boundary. Is there a ...
17
votes
3answers
6k 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 ...
15
votes
3answers
2k views

Can Mathematica's random number generation be improved?

Performance on Random Number generation is intolerable. Whenever you need many deviates from the same distribution but with different parameters it takes forever. Here is a thread on Poisson ...
38
votes
5answers
4k 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. ...
19
votes
1answer
540 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: ...
17
votes
3answers
6k views

How to generate random directed acyclic graphs?

How to programmatically build random directed acyclic graphs (DAG)? I know about the AcyclicGraphQ predicate and the ...
16
votes
1answer
678 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 ...
3
votes
2answers
250 views

generating randomly oriented non-intersecting cylinders

I could not find anything relevant with "googling" (only this) I can create a set of randomly oriented cylinders (code found here) ...
4
votes
1answer
798 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 ...
114
votes
7answers
20k views

How to generate a random snowflake

'Tis the season... And it's about time I posed my first question on Mathematica Stack Exchange. So, here's an holiday quest for you Graphics (and P-Chem?) gurus. What is your best code for generating ...
45
votes
3answers
3k views

Quality of random numbers

Mathematica has several ways of generating random numbers: Congruential, ExtendedCA, Legacy, MersenneTwister, MKL, ParallelGenerator, ParallelMersenneTwister, Rule30CA. For ...
32
votes
1answer
2k 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 ...
15
votes
3answers
3k views

Create triangular mesh from random list of points

I have a list of points. I would like to take these points and create a mesh of triangles from them, making sure triangles don't overlap. So here's a list of points: ...
10
votes
3answers
3k 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$.
8
votes
2answers
603 views

Monte Carlo integration with random numbers generated from a Gaussian distribution

I want to do numerical integration of some functions using the Monte Carlo method. The default setting for the Monte Carlo method is to use a uniform distribution as far as I know. How can I change ...
8
votes
3answers
473 views

Turning a set of random walk data 45 degrees

I have a set of data that is just a "random" (generated by me, not by computer) sequence of length 2000 of 1's and (-1)'s. I used it to plot a 1-D random walk where +1 is step up, (-1) is step down, ...
7
votes
5answers
2k views

Random numbers that sum up to specific value

I would like to generate a list with random numbers, which add up to a specific value. While[Total[x] == 28, x = RandomInteger[{0, 28}, 5];Print[x]] The random ...
3
votes
4answers
1k views

Random real numbers that sum up to specific value [duplicate]

In here, it works with "Integer". What if I want 5 positive real numbers that sum to 1? RandomChoice[IntegerPartitions[100, {5}]]/100. That will work. But only ...
1
vote
3answers
393 views

Random non-overlapping disks in a square

I've found a nice code snippet by @belisarius from this question, that I'll reproduce here for reference: ...
13
votes
1answer
394 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 <...
12
votes
4answers
672 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. ...
4
votes
1answer
298 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
1k 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 ...
18
votes
4answers
2k 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 \leq 1$ in the first octant: ...
12
votes
4answers
2k 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 ...
21
votes
3answers
2k 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 ...
21
votes
2answers
1k 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 ...
17
votes
5answers
1k 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. ...
15
votes
2answers
700 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 ...
19
votes
3answers
918 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 ...
8
votes
1answer
376 views

Inconsistent DistributionFitTest results?

In pondering this question, I used Mariana's function to generate the following data. ...
16
votes
1answer
259 views

Why does't SeedRandom work here?

From the docs on SeedRandom, SeedRandom[] resets the generator, using as a seed the time of day and certain attributes of ...
14
votes
5answers
565 views

How can I generate and randomly assign color to annular sectors?

How can I generate such an image and fill every annular sector with a random colour?
28
votes
3answers
443 views

Assign a randomly generated list to variable

Bug introduced in 10.0.0 and fixed in 10.0.2 I don't know if this is a silly question, but it really baffles me. So please help me understand this behavior. ...
6
votes
4answers
657 views

Random sampling of multiple integers with constant sum

I want to build a model of 40 geological layers, assuming each layer has equal chance to be one of the four types of rocks and the four types of rocks have equal chance to appear in any layer. The ...
4
votes
2answers
526 views

Boundary condition for stochastic differential equation

I have a simple stochastic differential equation (SDE) with white noise: ...
4
votes
1answer
851 views

How do I get a list of unique random integers? Avoiding numbers being drawn twice [duplicate]

I am trying to get a set of random integers for which I used the function RandomInteger[{1, 50}, 5]. That way, however, there is the chance to get doubles such as <...
1
vote
1answer
1k 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, ...
6
votes
2answers
111 views

Sum considers RandomInteger[] as a constant

Perhaps this is expected behavior, but I was kind of surprised by the following: ...
5
votes
1answer
110 views

Huge overhead in RandomPoint[ImplicitRegion]

Commenting answers of this question @JasonB noticed the big overhead of RandomPoint ...
3
votes
3answers
190 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]]; ...