Questions tagged [random]

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

Filter by
Sorted by
Tagged with
3
votes
2answers
124 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
66 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
86 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
58 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
23 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
246 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
313 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
149 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 ...
1
vote
0answers
27 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
185 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
128 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
76 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
49 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
67 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
172 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
369 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
178 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
35 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
221 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
38 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
49 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
44 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
91 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
47 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
121 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
38 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
195 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, ...
4
votes
2answers
142 views

How to find random values of variable satisfying multiple conditions?

I have multiple conditions to be satisfied ...
0
votes
0answers
37 views

ItoProcess with WhiteNoiseProcess

Is there a way to use ItoProcess with a white noise process, instead of the usual WienerProcess? If I just naively use ...
-1
votes
1answer
53 views

Can the WishartMatrixDistribution command be used for generating random density matrices?

I am interested in generating random members of two classes of $n \times n$ positive-definite matrices $A$ and $B$--the former symmetric in nature, the latter, Hermitian. The standard (Ginibre-matrix-...
1
vote
1answer
58 views

Obtain fairly sampled data set subject to a condition?

I need to obtain a random distribution of some parameters {t1,t2,t3} subject to a set of conditions. For example, ...
0
votes
0answers
53 views

Generating and operating with random number

I'm working basically with the creation of random numbers that represent the positions of $N$ electrons within a box. Later, I sum all the individual electric fields generated by the electrons, thus ...
0
votes
1answer
28 views

How to find multiple groups of solutions that meet the requirements

I want to find multiple nonzero real matrices A, B that satisfy $A.B=\mathbf{0}$ condition. ...
0
votes
1answer
111 views

Generate random matrix with specific eigenvalues [duplicate]

I want to generate some matrices of order 3 with eigenvalues 1,2, -2. ...
0
votes
1answer
52 views

How to quickly generate a nilpotent matrix?

At present, I want to generate some random matrices whose nth power is zero matrix. ...
0
votes
1answer
49 views

RandomReal inside a loop

I want to perform the following series summation: $$\sum_{j=1}^5 \exp\left[{-\beta \, \left(\text{En} + \frac{\Delta \, X}{Num} \right)}\right] \cos{\left(\text{En} + \frac{\Delta \, X \, T}{Num} \...
0
votes
0answers
48 views

Using RandomVariate in a NDSolve

I want to solve a version of the Langevin's equation using RandomVariante with a normal distribution. Therefore, I used the next code: ...
1
vote
1answer
31 views

Select a subsequence of a sequence according to tosses of a biased coin

I have a sequence, from which I would like to select a subsequence, each term of the original sequence being included in the subsequence with probability $p$, independently of the other terms. That is,...
2
votes
3answers
144 views

RandomPoint fails for any higher dimension

region = ImplicitRegion[x^2 + y^2 + z^2 + p^2 == 1, {x, y, z, p}]; RandomPoint[region] The result is RandomPoint[ImplicitRegion[x^2 + y^2 + z^2 + p^2 == 1, {x, y, z, p}]],and how can I attain two ...
6
votes
1answer
54 views

Generate a random list that have 2 different ranges in 2 dimensions

Here is my thing. Each element in the list has its own range. {RandomReal[{0, 1}], RandomReal[{0, 2 Pi}]} This code alone can only generate a point. Is it ...
4
votes
2answers
146 views

How to add Spheres[] sequentially from the surface of preexisting spheres?

I'd like to connect many spheres, by adding a new sphere at some point that's sitting on the surface of a previous sphere. How could we do this? Suppose I have a unit sphere and a point on it: ...
7
votes
1answer
128 views

How to distribute points on a Sphere[] cap from a normal distribution?

I was wondering if one could distribute points on a "cap" of a sphere, following a normal distribution of the points instead of a uniform distribution. This normal could be centered at the ...
2
votes
1answer
94 views

Dynamic Update for 2D Random Walk

I have code for a random walk ...
0
votes
0answers
30 views

Correlated random variables

Assume we have a random variable $X(t)$ that changes as a function of time satisfying a correlation $\left\langle X(0) X(\tau) \right\rangle=e^{-\tau/\tau_c}$. Is Mathematica able to generate random ...
3
votes
2answers
69 views

Random Sample from Very Large Table

I'm currently trying to create some test data to check a numerical implementation against Mathematica's implementation of some functions. In order to do this, I've been generating a broad range of ...

1
2 3 4 5
15