# Questions tagged [random]

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

787 questions
Filter by
Sorted by
Tagged with
30 views

63 views

### Antithetic Variates in Monte-Carlo simulations (code taking too long to execute)

I am trying to use the Antithetic Variates method to reduce error in stock price estimates. Essentially, I generate pairs of negatively correlated RV's and use them to simulate stock price. The ...
64 views

### Random interior points of a demi circle [closed]

I am trying to write a code in Mathematica that allows me to find random points in this half circle by knowing the center and the radius. Each time I test something I find myself with a point out of ...
167 views

### Random real antisymmetric matrix [duplicate]

Is there a way to create random real antisymmetric matrix in Mathematica. Please see the example of such a matrix.
115 views

### Why isn't RandomPoint evaluating?

Consider the expression RandomPoint@ BooleanRegion[#1 && ! #2 &, {Sphere[{0, 0, 0}], ConicHullRegion[{{0, 0, 0}}, {{1, 1, 1}}]}] This does not ...
67 views

### Simulating electrons passing through a beam splitter for random number generation

I would like to write a program that would simulate the trajectory of an electron/photon passing through a 50-50% beam splitter and depending on which detector the particle is measured, it would ...
512 views

### Why do changing the limits of RandomInteger not affect the result?

Recently I noticed (on Windows 10, Mathematica 12.1) that changing the limits of RandomInteger, while keeping SeedRandom fixed, ...
32 views

### How to generate the low discrepancy Halton sequence in Mathematica and plot it?

Pre-requisite Definition For any integer $n\geq 0$ and base $b \geq 2$ as follows, we define the following function, known as the radical-inverse function, \begin{align} \phi_b(n)=\sum_{j=1}^m a_j b^{-...
43 views

### Mean of Randomvariable

I want to calculate Mean[x+y]. x = NormalDistribution[] y = NormalDistribution[] Mean[x + y] ...
43 views

### How do I generate a random permutation of a (long [millions-length]) list of symbols? [closed]

I have a list of length twelve: p = {t[1, 1], t[1, 2], t[1, 3], t[1, 4], t[2, 2], t[2, 3], t[2, 4], t[1, 5], t[3, 3], t[3, 4], t[1, 6], t[4, 4]} and a set of ...
86 views

### How to generate an heterogeneous mesh

I'd like to generate a mesh with a big variance in cell size. Something like I'd prefer not to rely on a vertex model and perhaps use something simpler, like ...
153 views

### How can I speed up this Monte Carlo integration for the Stieltjes constant $\gamma_n$?

Pre-requisite Definition Stieltjes constants ($\gamma_n$) are the constants that occur in the Laurent series expansion of the Riemann zeta function. {\displaystyle \zeta (s)={\frac {1}{s-1}}+\sum _{...
223 views

### Generate 3 dimensional random vectors

How can one generate a random vector $v=[v_1, v_2, v_3]^T$ satisfying $\sqrt{v_1v_1^* + v_2 v_2^* + v_3 v_3^*} = 1$, where $T$ and $*$ denote the transpose and complex-conjugate, respectively?
140 views

### How to throw $n$ random noodles of equal length?

I've been meaning to modify some code given in the the Region Disjoint documentation for the Buffon's Needle problem to instead model Buffon's Noodle Problem. In Buffon's Needle problem you randomly ...
55 views

### Multinomial Distribution Sampler not working

I am trying to sample from a multinomial distribution many times but with a different multinomial distribution each time. The straightforward ...
157 views

### Implementation of Bean machine (Galton board)

Bean machine is a triangular array of pegs, Balls are dropped onto the top peg and then bounce their way down to the bottom where they are collected in little bins.Each time a ball hits one of the ...
85 views

### How to generate random variate in custom domain for a distribution?

I have a distribution defined in a particular domain of the variable but now I want to generate a random variable not in the entire domain but only in a subset of the domain. Here is what I'm trying ...
56 views

### Stochastic noise with known propability density function

How can I generate samples for random function, which functional "probability density" is known? When I say "probability density" for random function $\xi(\mathbf{q},t)$, I mean, ...
108 views

### Creating random differential equations

I'm working on an educational project and new to Mathematica Language. Can I create,like multivariance equations with different f[x] in y'[x]=f[x] by using one function? The output should be like this:...
36 views

### Simulating jump Markov process

I am trying to simulate a jump Markov process as follows. I define the process $N_j = N_{j-1} + 1$ with probability 1/2 or $N_j = N_{j-1} - 1$ with probability $1/2,$ with $N_j = 0$ as an absorbing ...
61 views

### Ndsolve of random (periodic) initial conditions via BSplineFunction

Suppose we want to solve the heat equation for a random initial temperature field T(t,x,y). Therefore I define the initial conditions with the BSplineFunction which nicely incorporates periodic ...
74 views

### Creating a list of $xy$ pairs

How do I create a list of $xy$ pairs of points where the $x$ points are evenly spaced between a given range with a specific step size, and the $y$ points are given by a function, but with some random ...
37 views

### Replace points on a grid with numbers to maintain order

I am DMing a game of DnD and one of my players is really into fear effects, which is cool, but the effect of having monsters suffer from the "panicked" condition gets tedious to render via ...
121 views

### Drawing the filled Julia set of a polynomial

Suppose I use JuliaSetPlot to draw the Julia set of a polynomial. Is there a way, assuming the set is connected, to fill in the region? My idea was to use ...
51 views

### How to generate a random matrix with arbitrary correlation between elements?

I would like to find a smart way to generate a $N\times N$ random matrix $M$ with arbitrary correlation: \begin{equation} \boxed{\langle M_{ij}M_{kl}\rangle=\tau_{ijkl}} \end{equation} Where the mean ...
154 views

### Efficient uniform sampling of certain Boolean matrices

I want to uniformly sample $(0,1)$-matrices with certain constraints. In particular, I want sum of each row to be rowsum and the sums of columns to equal ...
85 views

### How to generate randomly points that belong to the given range?

Consider some rectangle called ExperimentLocation, and a circle ParticleAzimuthalCoverage: ...
51 views

### Random composite integer n with 200 digits and Miller-Rabin witnesses [closed]

I wanna take a random composite integer n with 200 digits and check how many, out of 100 random integers, that are Miller-Rabin witnesses for compositeness of the integer n. The first thing I need to ...
70 views

### Calculate the Viswanath's constant (Random Fibonacci sequences)

How Can I calculate first few digits of Viswanath's constant? Viswanath’s constant ≈ 1.1319882487943 is a real number whose nth power approximates the absolute value of the nth term of some random ...
92 views

### How to create random isolated clusters periodically?

Let's assume we have a $n \times n$ grid repeated periodically, and I want to create some random isolated patches on it (and assign some value to those grid points). For a simple example consider this ...
75 views

### Function to determine number of trees surviving forest fire [duplicate]

How can I write two functions, each of which have as their argument an array mat of 0s (no trees), 1s (trees), 2s (burning trees), that can determine the trees that survived a forest fire, which run ...
46 views

### Problem getting values from a 2D array. Possible problem of denoting variables?

I am trying to setup a system of 100 coins. All the coins are starting off as heads (0). flips = Array[0, 100]; tails = Array[0, 100]; heads = Array[0, 100]; I ...
265 views

### Generate symmetric random tensor

I would like to generate a table $T$ of random values of rank $p$ such that my table is fully symmetric: If I swap any indices I get the same value. For example when $p=3$ I would like $T_{ijk}$ to be ...
222 views

### Function to create random matrix, then a simulation. *EDIT* Create two functions

How can I write a function with parameters b, i, and j, which would return a i x j array of 0s, 1s, and 2s, but the array needs to be populated randomly with 0s and 1s which have respective ...
60 views

### Generate random numbers in such a way that their combinations meet the specified conditions

We need to generate 5 numbers $\alpha,\beta,p,q,k$ so that they meet the following conditions: $\alpha,\beta,p,q,k>0$ $k \cdot p <1$ $k \cdot q >1$ Edit: I think, that this code may be ...
67 views

### Numerical simulation

I want to generate a numerical simulation in table for an equational output. I have used following code. But somehow I can't get any output. I am very novice to Mathematica. Can anyone please ...
28 views

...
57 views

...
56 views

...
491 views

### 2-dimensional random walk

b = RandomVariate[NormalDistribution[0, 1]]; ListlinePlot[b, PlotRange -> 35] I am so new to Mathematica. I am trying to generate a 2-dimensional walk with ...
Currently I am trying to delete a randomly-chosen $i^{th}$ row and column from a square $n \times n$ matrix $A$. So far I come up with the following code: ...