Questions tagged [random]

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

Filter by
Sorted by
Tagged with
1
vote
2answers
23 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
1answer
69 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
42 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
146 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
77 views

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

Consider some rectangle called ExperimentLocation, and a circle ParticleAzimuthalCoverage: ...
0
votes
1answer
47 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
55 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
85 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
74 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
44 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
246 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
214 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
57 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
62 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
27 views

Random Walk under a Uniform Distribution

...
3
votes
1answer
53 views

Random walk based on uniform distribution

...
1
vote
0answers
50 views

A Random walk with gaussian step

...
5
votes
2answers
480 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
142 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
78 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
94 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
30 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
64 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
25 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
263 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
331 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
160 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
35 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
204 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
71 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
82 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
48 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, \:\...
2
votes
1answer
50 views

How to insert variable height in this random bumps function?

I'm trying to insert a "time" variable that control the height of the random smooth bumps, but I'm yet unable to do it right, as shown with the code below: ...
3
votes
1answer
80 views

How to define a smooth function of random bumps in a plane?

I would like to define a simple function that gives random smooth bumps in a plane, a bit like the clumsy picture below, but it should be continuous: ...
4
votes
3answers
181 views

How to draw borders around tiles of the same color?

I'm having difficulties with a project to show random tiles with a few random colors. Here's the code that I need to modify: ...
4
votes
3answers
388 views

How to draw random colorfull domains in a plane?

I'm trying to produce some graphics like the one shown below, with a few adjustable parameters to change the number and size of cells. The cells positions, sizes and colors should all be random (size ...
4
votes
2answers
182 views

Maximum of all distances between any pairs of vertices of a random triangle

Given a set $S_n$ of $n$ points selected uniformly at random in a $d$-ball, I want to estimate the average length of the longest side of a triangle having as vertices any three distinct points of $S_n$...
1
vote
1answer
40 views

How to add noise to these random straight lines in 3D?

Here's a code that draws a pack of random straight lines in 3D: ...
6
votes
2answers
226 views

How to generate randomly curved and twisted strings in 3D?

Here's a code that draws a set of random straight lines in 3D: ...
0
votes
1answer
39 views

How to define new random numbers in a table?

I'm trying to generate a plot of a few random straigth lines in 3D using the code below: ...
0
votes
1answer
53 views

Function to spot randomness and/or predict future data

Does Mathematica have a good function to show if a series of discrete data are random or have some hidden periodicity about them? Am I correct in thinking Fourier analysis is best suited for that. ...
1
vote
1answer
47 views

Implementing Random process for exponential correlation function

I'm trying to simulate a random process for a variable $-1<X(t)<1$ with average 0, i.e., $\left\langle X(t)\right\rangle =0$ and correlation $\left\langle X(t)X(0) \right\rangle \propto e^{-t/\...
1
vote
1answer
99 views

Randomsample without repetition [closed]

I'm looking for a simple way to generate random samples of lists of integers such that each time I sample I'm sure it chooses a new random sample. This is closely related to Picking random items out ...
1
vote
2answers
49 views

Is there a discrete random variable function with which I can specify the probability of returning a value?

I am trying to create a function s[n_] which returns a subset of $\{ 1,2,3 \dots n\}$ wherein each integer $j$ appears with probability $1/j$; ie. there is a $1/4$ ...
5
votes
1answer
127 views

How to display an image pixel by pixel randomly

I want to display an image that each pixel appears randomly, the final result is an image without noise. I have tried this, but the result is not what I expected, How should I fix it? ...
0
votes
0answers
25 views

Using If commands with nested lists

been beating my head against a wall with this question: 2 people play a marble rolling game. 1 person gets 1 roll, the other gets 2 rolls. The person with the roll the closest distance to a certain ...
1
vote
0answers
32 views

How to count the amount of times an element appears seperately within a nested list [closed]

Beginner at using Mathematica, and having trouble with nested lists. For example, the following output for 15 coinflips every day for a year: ...
0
votes
0answers
40 views

Piecewise function inside ProbabilityDistribution causing errors

I'm using a complicated Piecewise function to create a probability distribution and draw random points from it. ...
3
votes
2answers
286 views

Generating a random density matrix in Mathematica

I am interested in using Mathematica to generate random $N\times N$ density matrices describing pure quantum states; for the less physics-oriented folks, a density matrix is positive semi-definite, ...

1
2 3 4 5
16