Questions tagged [random]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
62 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 ...
11
votes
1answer
497 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, ...
0
votes
0answers
27 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^{-...
0
votes
1answer
41 views

Mean of Randomvariable

I want to calculate Mean[x+y]. x = NormalDistribution[] y = NormalDistribution[] Mean[x + y] ...
1
vote
0answers
32 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 ...
5
votes
1answer
75 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 ...
4
votes
1answer
149 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 _{...
4
votes
2answers
204 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?
4
votes
2answers
138 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 ...
0
votes
2answers
52 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 ...
4
votes
2answers
141 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 ...
3
votes
1answer
75 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 ...
1
vote
0answers
53 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, ...
2
votes
1answer
102 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:...
0
votes
1answer
35 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 ...
0
votes
1answer
56 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 ...
1
vote
2answers
69 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 ...
1
vote
2answers
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 ...
0
votes
2answers
111 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 ...
1
vote
1answer
47 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 ...
8
votes
2answers
151 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 ...
0
votes
1answer
80 views

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

Consider some rectangle called ExperimentLocation, and a circle ParticleAzimuthalCoverage: ...
0
votes
1answer
50 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 ...
2
votes
2answers
59 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 ...
3
votes
1answer
89 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 ...
0
votes
0answers
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 ...
3
votes
1answer
45 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 ...
3
votes
2answers
258 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 ...
6
votes
2answers
216 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 ...
0
votes
2answers
58 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 ...
0
votes
1answer
65 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 ...
0
votes
1answer
28 views

Random Walk under a Uniform Distribution

...
3
votes
1answer
56 views

Random walk based on uniform distribution

...
1
vote
0answers
51 views

A Random walk with gaussian step

...
5
votes
2answers
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 ...
3
votes
2answers
149 views

Replacing a random ith row and column from a matrix

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: ...
0
votes
2answers
86 views

How to generate random vectors without repetition?

Say we have three elements, 0,1,2 and we want to generate 1000 random vectors of length 7 with these elements, i.e. {2,1,0,0,0,0,2} How can we do this without ...
2
votes
1answer
97 views

Speeding up code doing random sampling

I have a particular probability distribution (that is a function of a parameter $\phi$), that I would like to sample from and then do a listplot for that function. Here is the code that I came up with:...
1
vote
1answer
32 views

How to store and print the same RandomInteger value that met a condition in a Do loop?

Let's suppose that we want to use random guessing to find a matrix G that satisfies the relation F=G.{x,y}: F={x+y} ...
1
vote
1answer
65 views

Specifying statistical models / Equations between Random Variables [closed]

I'm new to Mathematica and confused about how random variables work. Say I have a standard normal random variable $X\sim \mathcal N(0,1)$ and set $Y := 2X$. Then $\operatorname{Cov}(X,Y) = 2$. Now if ...
0
votes
0answers
28 views

Computation of 1- and 2-sided p-values for Fisher's Exact test for 2x2 table based on Monte Carlo

I am looking for code to compute the 1- and 2-sided p-value for Fisher's Exact test for 2x2 tables based on Monte Carlo (bootstrap simulations). For larger 2x2 crosstabulation tables, the exact p-...
4
votes
2answers
275 views

How to create a smooth black and white texture without jaggies?

The following code creates a random black and white texture with ugly jaggies (pixelized "stairs") all around the shapes, because of the Binarize command. ...
4
votes
5answers
341 views

Randomly Choose from list but meet conditions

I have a list of integers from 0-99, but some of the integers have been randomly removed. I want to pick a random integer that is still in the list, let’s call it ‘a’ but if a+1, a+2, and a+3 are not ...
4
votes
3answers
163 views

Empirical mean excess plot of (μ, e(μ))

Say I generated n random variates from the standard cauchy distribution. I want to construct the empirical mean excess plot of (μ, e(μ)) , where e(μ)={Σ(xi-μ) *I {xi>=μ}}/Nμ . Nμ is the number of ...
2
votes
0answers
47 views

How to define smooth random initial conditions consistent with boundary conditions for this 1+2D PDE?

I wrote a fully working code to numerically solve a non-linear variation of the classic 1+2D waves equation. Here's a stripped down version of it (classic waves equation), with static initial ...
8
votes
2answers
233 views

Generate random lines that don't be too crowded between the intersections

It's easy to generate random lines, such as this ...
1
vote
2answers
73 views

How to simplify this sum of random waves?

Is there a way to simplify the random functions and their calls, in the code below? ...
2
votes
1answer
131 views

How to make this moving surface a continuous and derivable function?

I'm having troubles in defining a function of three variables: $t$, $x$, $y$, from a moving bumpy surface that should be derivable relative to its three variables. Here's the animated surface code, ...
1
vote
1answer
92 views

Randomly oscillating surface is not working well

I'm trying to built some random moving surface from a plane perturbed with random oscillators, and my current code isn't doing what I need yet, as seen from the ...
1
vote
1answer
49 views

distribution implement for RandomVariate

I have a scalar function of two random matrices of dimension $n$ which are in the Gaussian Unitary Ensemble $$f(x,y) \in \mathbb R, \quad x^{\dagger}=x \: \operatorname{and} \: y^{\dagger} = y, \:\...

1
2 3 4 5
16