Tagged Questions

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

810 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 ...
360 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 ...
3k 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. ...
771 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 ...
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 ...
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 ...
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 ...
925 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? ...
333 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 ...
912 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 ...
809 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 ...
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, ...
394 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 ...
180 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 ...
735 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 ...
402 views

RandomVariate returns values outside the support of a PDF

Bug introduced in 8.0.1 and fixed in 10.2.0 Let $X$ be a random variable with pdf: dist = ProbabilityDistribution[1/(Abs[x]*Log[Abs[x]]^2), {x, -E^-2, E^-2}] ...
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 ...
538 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: ...
115 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 ...
653 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 ...
1k 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 ...
433 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 ...
322 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. ...
668 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 ...
717 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 ...
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 ...
140 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. ...
280 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 ...
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 ...
4k views

How to generate random directed connected graph?

How to generate random directed connected graph? I need to create graph which will pass: ConnectedGraphQ[^]
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$.
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?
4k 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 ...
712 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 ...
183 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: ...
882 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 ...
2k 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 constraints"...
4k 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 ...
178 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, ...
769 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 ...
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 ...
2k 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 ...
135 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: ...
869 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 ...
685 views

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 ...
1k 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.
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 ...
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. ...