Questions tagged [random]

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

Filter by
Sorted by
Tagged with
6 votes
3 answers
227 views

Incrementing a random element of an array repeatedly

Consider this code to simulate a simple instance of the coupon collector problem. We initialize an array to {0, 0} and then keep incrementing a random element until we've incremented every element at ...
dreeves's user avatar
  • 696
0 votes
2 answers
75 views

Appending Random Number to Existing List

My goal is to append random number to list like below.The problem is whenever I try appending a random number, the previously created numbers are changed which I don't know why. How to add a random ...
Soon's user avatar
  • 399
6 votes
2 answers
234 views

Split a sequence with conditions

I need a function which splits a sequence of arbitrary length at x random points and which guarantees that each partition (bin) contains a minimum of ...
eldo's user avatar
  • 48.8k
1 vote
1 answer
74 views

Unwanted reevaluation in Manipulate with RandomPointConfiguration

Here is a simple illustration of a problem I am encountering. I want to use RandomPointConfiguration inside Manipulate, but it ...
Russ Lyons's user avatar
1 vote
2 answers
169 views

How to use first time generated randomly matrix? [closed]

I'm trying to solve one (very little) problem. :) I've generated 3x3 randomly matrix with V[i_, j_] := Table[RandomInteger[{-10i, 10j}], {3}, {3}]; Now I want to ...
stoboja's user avatar
  • 19
0 votes
0 answers
40 views

Combinations of distributions to be called with `RandomVariate`

I'd like to manipulate distributions that I'm going to retrieve using RandomVariate; e.g., I would like to take ...
zjs's user avatar
  • 153
11 votes
4 answers
964 views

How to create a random zonogon?

A zonogon is a polygon that is convex and is made only out of pairs of parallel sides with the same length. Any regular polygon with an even number of sides is an example of a zonogon. When I use: <...
Teg Louis's user avatar
  • 403
3 votes
2 answers
157 views

Approximate a Wiener Process by a Karhunen-Loève expansion

I'm trying to approximate a Wiener Process by a Karhunen-Loeve expansion (see slide 20) with the following code: ...
Stratus's user avatar
  • 2,882
3 votes
2 answers
205 views

Fill data points within the boundary established by the given points

I have the following data points: ...
葉柏樂's user avatar
  • 135
1 vote
1 answer
83 views

How to select the points that belong to the given region?

Consider two regions: ...
John Taylor's user avatar
  • 4,681
2 votes
1 answer
185 views

Applying NDSolveValue on a differential equation

I am trying to solve stochastic Schrodinger equation (Schrodinger equation in the presence of Ornstein Uhlenbeck Process) $$i\frac{d}{dt}\begin{pmatrix}c_1(t)\\ c_2(t)\end{pmatrix}=H(t)\begin{pmatrix}...
Radmehr's user avatar
  • 51
4 votes
5 answers
222 views

How to delete the complex numbers which are generated in a list of numbers?

Here I have generated a list of numbers ...
Sangeeta Dey's user avatar
1 vote
0 answers
106 views

Random Seed and Parallelization in Compiled Functions

I am having trouble reproducing a random number from a compiled function with parallelization even with the random seed being set. Specifically, running the following script should give the same value ...
Kohei's user avatar
  • 11
3 votes
2 answers
120 views

How can I use replacement rules with randomized values? [closed]

Suppose I have a list that I want to use replacement rules to replace each occurrence of a a given symbol with a randomly selected value, with this choice being randomized for each occurrence. For a ...
erfink's user avatar
  • 1,089
1 vote
0 answers
37 views

How can I use RandomFunction to solve an SDE in reverse time?

I am working with a problem of the Ito-stochastic differential form given by $$\mathrm{d}x=g(x,t)\,\mathrm{d}t+f(x,t)\,\mathrm{d}W,$$ where $W$ is a Wiener process. I furthermore have to satisfy the ...
JAC's user avatar
  • 21
3 votes
2 answers
111 views

Update Random Each Repetition of Animate

I found a solution that's not what I wanted but it will suffice Thanks - Larry ...
L. Gorham's user avatar
1 vote
3 answers
135 views

Plotting Average Positions of 2D Random Walk

I need to generate a plot that shows the averaged position at n steps of 1000 different random walks that are each 1000 steps long. So far I am using ...
Mandty24's user avatar
0 votes
0 answers
24 views

Smoothening noisy distributions to learn eigenvalue statistics

I have a problem involving random matrices, in which I'm trying to learn properties of their spectral statistics. The problem I'm having can be boiled down to a list management issue, but I will begin ...
miggle's user avatar
  • 647
0 votes
1 answer
58 views

How to get the time series of colored noise obtained by AudioGenerator function?

In the documentation I found a code that plots a Periodogram. ...
Maksim's user avatar
  • 1
1 vote
1 answer
84 views

How to get randomly arranged image in Mathematica?

I'm now thinking about randomly arrangement of the imported image. After importing 2 hand-written images, image1 and image2, I want to make each 5 copys and randomly arrange them in one graph, i.e. ...
rani's user avatar
  • 111
0 votes
0 answers
73 views

How to generate points belonging to some region very fast?

Consider two variables Ex,th. th ranges within thmin=10^-5; thmax=Pi/2; while ...
John Taylor's user avatar
  • 4,681
4 votes
1 answer
229 views

Illustrating the central limit theorem

I'm working on this question is from Wolfram Mathematica online course. I tried my best to find the answer, still not getting it right The question is: Make a list of histograms of 10000 instances of ...
Ratheesh's user avatar
  • 307
1 vote
1 answer
90 views

Why is generating normalized random $1000 \times 1000$ matrices and plotting the eigenvalues so slow?

For each of the distributions $N(0,1)$ and $\pm 1$ equal probability and for each of $N \in \{5,10,20,50,100,200,1000\},$ I want to generate an $N \times N$ matrix with entries chosen from the ...
Display name's user avatar
1 vote
1 answer
129 views

Wolfram Mathematica Monte Carlo for integrals approximation

I wanted to implement the Monte Carlo method for multiple integrals approximation in Wolfram Mathematica. Namely I wanted to let the user insert as input the dimension of the integral and the number ...
Greg's user avatar
  • 11
2 votes
1 answer
52 views

How to predict number from a set of data?

I have 2 sets of data. For example, ...
user8357568's user avatar
8 votes
1 answer
289 views

Creating a random symmetric matrix with a particular rank

The documentation about LinearAlgebra has a section on Constructing Matrices, but the examples of random matrices using RandomReal don't offer an obvios way to ...
lotus2019's user avatar
  • 1,943
0 votes
2 answers
68 views

Table generation with random variates inside. Mathematica [closed]

I'm new on this forum, and I'm also a new user of the software Mathematica. For this reason, I'm sorry if my question will be unclear and / or dumb. I have to make a numerical simulation with random ...
Gabriel T's user avatar
0 votes
1 answer
79 views

Bad performance of 3D self-avoid persistent random walk with periodic boundary conditions

I'm trying to simulate a self-avoiding persistent random walk with periodic boundary conditions a large number of times. For some reason, the script I've written is extremely slow for self-avoiding ...
M  .  M's user avatar
  • 105
0 votes
0 answers
51 views

Changing permutation dynamically

I am trying to make a visualization of permutation as a graph. With the first compilation of program I want to get random permutation and then be able to dynamically change permutation that I desire ...
jkjfgk's user avatar
  • 21
0 votes
2 answers
44 views

Cannot use RandomSample to get a sample bigger than the original [closed]

I have a sample of 300 elements and I need a random vector of size 100000 which consists of random repetitions of the elements of the 300-element sample I have tried the following ...
slow_learner's user avatar
1 vote
1 answer
95 views

Speed up random set partition code

I have managed to construct code for randomly generating a set partition of size n with k parts. Note that the total number of such objects is counted by a Stirling number of the second kind. The code ...
Per Alexandersson's user avatar
0 votes
1 answer
66 views

Check if NDsolve solution of nonlinear second order eq. is random

I'm solving second order nonlinear eq. using NDsolve. I'm interested in y'(t) dynamics (plotted below). The thing is - from this solution I'm not sure if we have some randomness or it is just complex ...
denkorw's user avatar
  • 181
1 vote
0 answers
99 views

How to construct an orthogonal matrix with the elements taken from a uniform distribution?

I want to construct an Orthogonal matrix such that its elements are randomly chosen from a uniform interval $[-r,r]$ in Mathematica. The way I am doing it is by simply constructing a matrix whose ...
Erosannin's user avatar
  • 187
0 votes
0 answers
38 views

What is the best memory utilization and efficiency considerations for simulating particles that are randomly created and removed?

I am wanting to run a simulation involving a varying number of "particles" (points defined by 2D coordinates $(x,y)$ within some region). At each time step, there is a probability that a new ...
BioPhysicist's user avatar
2 votes
2 answers
256 views

Randomly colored and randomly sized points in a region

I am trying to show random points with different colors and sizes. However, the following code generates random points with the same color. I want them in different colors. I think I have a problem ...
user84456's user avatar
  • 1,554
3 votes
3 answers
228 views

Plotting a unit length line given its midpoint and an angle

I have generated random 3-tuples: $(x, y, \theta)$ where $\{x, y\}$ is the midpoint of a unit length line and $\theta$ is its angle with respect to the x-axis. Is there a way to plot these lines ...
student's user avatar
  • 47
3 votes
3 answers
200 views

Randomly pick ten numbers from a table such that no two numbers are on the same row or the same column

I have generated a matrix as follows: Range[41, 50], Range[51, 60], Range[61, 70], Range[71, 80], Range[81, 90], Range[91, 100]]) // MatrixForm I was ...
SkySystem's user avatar
3 votes
1 answer
302 views

Stochastic process: Understanding Ornstein Uhlenbeck Process

Recently, I have been trying to simulate a random/stochastic variable that follows Gaussian distribution and also has an exponential correlation function $\left\langle X(t)X(s)\right\rangle= e^{-\frac{...
sined's user avatar
  • 573
0 votes
0 answers
79 views

How to uniformly distribute data points in all the region in a ListLogLogPlot

I've drawn a listLogLogPlot by generating random numbers. But the random numbers are not uniformly generated in all the region. More points are generated in the higher region than in the lower side. ...
Sangeeta Dey's user avatar
2 votes
0 answers
88 views

Solving stochastic equation

I am trying to solve, numerically, a classic stochastic Liouville's equation, namely \begin{equation} \frac{dA(t)}{dt} = -B(t)A(t)+ {\cal C}(t) \end{equation} with $B(t)=\cos(\omega t)$, and ...
sined's user avatar
  • 573
1 vote
3 answers
267 views

How to randomly generate points in a line?

For example,how to randomly generate 100 points in line L:y=x,and x~N(0,1). Edit:I mean,for point p(x,y),x=t,y=t,t is random variable,and t~N(0,1).Randomly generate 100 points like it.
眠之龍's user avatar
1 vote
1 answer
69 views

How can I calculate the moments of a truncated random variable?

I am using the Moment function to calculate the moments of an exponential random variable. as follows, Moment[ExponentialDistribution[3], 9] However, I need to ...
slow_learner's user avatar
4 votes
1 answer
176 views

Why won't my random walk work in a Mathematica Do loop? [closed]

This produces a nice random walk plot: ...
cybervigilante's user avatar
4 votes
1 answer
70 views

Speeding up RandomVariate with custom probability distribution

I have the defined a custom distribution, which is a Gaussian where the exponent can be any real n greater than 0 (set to actually be >0.5 in use), i.e. ...
Xyive's user avatar
  • 115
0 votes
1 answer
84 views

How to generate random value under the given distribution fast?

Consider a distribution distr[EN_, Enu_, mN_] = Exp[-(Sqrt[EN^2 + mN^2]/Enu)]*Sqrt[(Sqrt[Enu^2-mN^2]/2)^2 - EN^2] Sqrt[ EN^4 - (Enu/4)^4] where mN is a free ...
John Taylor's user avatar
  • 4,681
13 votes
1 answer
294 views

How can CompiledCodeFunctions be optimized and parallelized?

Fast generation of random variates as test case The earlier question (195435) about performance tuning with regard to fast generation of random variates for a gamma distribution has stirred my ...
gwr's user avatar
  • 13k
1 vote
3 answers
310 views

Weighted random choice from a list

I want to randomly choose one element from a list but preferring elements with small distance from the center of a list. How to do it properly say with normal distribution? I am not good at statistics....
azerbajdzan's user avatar
  • 9,903
10 votes
1 answer
693 views

Mathematica or math question: why my own Monte Carlo gives different result from the Mathematica's one?

Consider some function of arguments x,y,z, where the latter have some domain of definition $\mathcal{R}$: ...
John Taylor's user avatar
  • 4,681
4 votes
1 answer
113 views

How to speedup evaluation of a random point from an implicit region?

Consider three variables s2,t1,t2, and parameters ma,mb,m1,m2,m3,s. The domain of definition for s2,t1,t2 is given by the region Region3Particle: ...
John Taylor's user avatar
  • 4,681
1 vote
2 answers
126 views

How can I improve this code?

The code below is working well, but it's very slow in the Manipulate box. I know that the Do and AppendTo parts aren't very ...
Cham's user avatar
  • 3,969

1
2 3 4 5
18