Questions tagged [random]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
78 views

Apply RandomReal to list in list in Mathematica

I have a big list: {{1,1,1},{1,1},{1,1,1,1,1,1,1}....{1,1,1,1}} How can I apply RandomReal to every single element in the list?
11
votes
5answers
643 views

Evenly spaced points on boundary of polygon

I have a polygon and I would like to generate $n$ evenly spaced points along the boundary.
3
votes
1answer
178 views

Acceptance Rejection Method

I need to generate a random number (real) and then test if this number works on my pdf. if it works i append it to a list. if it doesn't, i reject it. Until now i have done this: ...
4
votes
0answers
138 views

Generating random coordinates (3D) with constraint

I have been trying to generate random $(x,y,z)$ coordinates (i.e. for 15 ellipsoids) so that they obey following constraints: ellipsoid's length is constant, ellipsoids do not intersect (fulfilled ...
3
votes
2answers
116 views

Optimize RandomVariate for a $1/x^4$ distribution

I'm working with the following code, where I define a probability distribution proportional to $1/x^4$. ...
0
votes
1answer
86 views

Generate random point on the external surface of this complex geometry

This is a followup to this question of mine. How do I generate a random point on the most external surface of this complex geometry? ...
1
vote
0answers
37 views

How to ask FindClusters to return the loss function value in the output?

I have some data points pts as below:- pts = BlockRandom[SeedRandom[123]; RandomReal[1, {100, 2}]]; Now I want to separate ...
5
votes
2answers
1k views

Generate “nice” random matrix

I don't frequent this community, so please give criticism if this is a poor question. I am trying to make a tool which generates a small (say, $4\times 4$) matrix with integer entries, which has a "...
1
vote
0answers
95 views

Bizarre error messages when monitoring random integers

I am doing tbl = {}; Monitor[ Do[AppendTo[tbl, RandomInteger[{1, 100000}, 2]], 100000], Length[tbl] ] (well in fact I am doing something less boring but what I ...
3
votes
1answer
102 views

How to generate a random real under a specified density function?

I want to generate a random real in the interval [0,1] according to the density function f(x) = 2x.
5
votes
1answer
419 views

Random walk in one dimension — meeting of two particles

I'm new to Mathematica and still teaching all by myself, hope you bear with me. I have the code: ...
1
vote
0answers
116 views

RandomVariate with a custom distribution [duplicate]

I have a customized distribution and I have to draw some random number from it. How do I use RandomVariate to draw random number from a custum distribution? My naive attempt ...
6
votes
3answers
265 views

Generate a random pattern with at-most n repeated consecutive elements

I want to generate a random pattern which has at-most n (>= 0) repeated consecutive elements from a sample space. The following example explains what I mean: ...
1
vote
1answer
86 views

Getting PDF from imported Histogram

So I'd like to create a probability density function from an existing histogram from a program that I use. My input data is of the form ...
4
votes
1answer
179 views

Sampling “Random” Cyclic / Acyclic Graphs

This is an extension of RandomGraph with specific constraints Where @Histograms wanted to make $n$ random graphs with a specific constraint (in @Histogram's case, having 2 vertices each with exactly ...
5
votes
3answers
134 views

Uniformly distributed numbers fulfilling conditions

I would like to generate 10 random lists of four elements (t, l, p, ...
1
vote
0answers
104 views

Understanding Maps and slot

Going through some old code I found this line: ...
14
votes
5answers
697 views

Smarter Shuffle of a List

I have a 2D matrix representing a keyboard: ...
7
votes
2answers
2k views

Can this code be changed to run faster?

I've worked for several days trying to get this code to run faster. The imported data is 15MB. ...
2
votes
1answer
81 views

Evaluation Time of RandomVariate Function

This question is about the runtime of the function RandomVariate. Take a simple normalized Gaussian distribution G on the real line, I tried to generate N random ...
8
votes
3answers
570 views

Creating a random matrix of no duplicates in both row and column from a given set list of elements

Say I have a list of letters {A,B,C,D,E,F,G,H}, I want to create an $4\times 8$ array where each row must not contain duplicates and each column must also not contain duplicates. Naively writing: <...
2
votes
1answer
150 views

Is a probabilistic primality test implemented in Mathematica?

Imagine that I need to verify that a specific integer, like $n = 10^{1347}+3049$ is prime. ProvablePrimeQ takes a lot of time, and, even if it will eventually work ...
7
votes
2answers
465 views

Creating a less random list

I'm trying to create an list like {1,3,2,5,8,7,9}, or {2,1,5,6,4,7,9}, that the elements in each list is sorted in a rough order,...
4
votes
1answer
169 views

Random particle motion

I have a foundational function that allows me to simulate particles moving in a box according to some movement function. The code is here: ...
1
vote
0answers
55 views

Looking for a way to run through every time step of a cellular automaton function with random seeds

I have been creating 2D cellular automaton functions in Mathematica and I would like the output to be a graphical representation of the array at each time step. I know I can do this with ListAnimate: ...
8
votes
1answer
213 views

Getting random points on a mesh region

So I have a region defined by a MeshRegion,like ...
5
votes
1answer
71 views

Random normalised variable generation

I want to generate 8 random variables (in reality to form 4 complex numbers) such that the sum of the 8 variables squared is equal to unity. The aim of generating such numbers is to perform a quantum ...
2
votes
4answers
148 views

How do I use the values generated in a for-loop in my first iteration to my next iteration?

This one is somewhat hard to explain, but I'll try my best to. I'm trying to generate a list of numbers (containing only pi/10, 0, -pi/10). Numbers are randomly selected from these 3, where the ...
0
votes
1answer
101 views

Defining a random potential on the unit square

I'm trying to define a random potential on the 2D unit square. For some fixed j, I want to decompose the unit square into $2^{2j}$ smaller squares with sides length $2^{-j}$. On each of the smaller ...
0
votes
1answer
37 views

How to (efficiently) generate and catch some data-set that has similar correlation?

...
3
votes
0answers
120 views

RandomPoint not evaluating on RegionQ and ConstantRegionQ regions

When attempting to recreate and generalise the MatLab code for Random Vectors with Fixed Sum by first principles I came across a few issue with RandomPoint. ...
3
votes
3answers
118 views

Random Point on Edge of Cylinder

How can I get a random point on just the curved edge of a cylinder? c = Cylinder[{{0, 0, 0}, {0, 0, 2}}, 2]; RandomPoint[RegionBoundary[c], 50] almost works, but ...
3
votes
0answers
50 views

RandomChoice inside RandomChoice

I have spent a half hour searching Mathematica.SE for information on this topic, with no luck. The code is: ...
1
vote
2answers
107 views

Using “RandomFunction” to simulate a Itoprocess with Random initial condition

I have an itoprocess such as: ...
0
votes
1answer
110 views

RandomReal left randomly unevaluated

Can anyone explain this? In Mathematica 11.1, I have a piece of code that uses RandomReal. Every so often I will throw up a RandomReal::array error. This happens ...
0
votes
0answers
23 views

Store the output values from a random sample [duplicate]

I am new to programming. I am defining x and y as random samples(as mentioned). Then I define a function h (of x and y). Now I want to get output values of h multiple times at once. I want to store ...
0
votes
1answer
260 views

Sphere Point Picking in Cartesian coordinates [closed]

I have a vector $\vec{A}(x, y, z)$. Now I want to rotate the vector randomly (x by ϕ, y by ...
7
votes
3answers
364 views

RandomPoint doesn't seem to work

I define a very simple sphere in 3D as follows: ℛ = ImplicitRegion[(x - 2)^2 + (y - 3)^2 + (z - 8)^2 == 1, {x, y, z}]; Now when I try to sample some 500 points ...
5
votes
2answers
226 views

Random sample of big big numbers

Consider the following piece of code: m = 2; n = 6; samplesize = 1000; totalsize = 2^(n^m); numbersample = 2 RandomSample[Range[totalsize/2], samplesize]; With ...
1
vote
1answer
196 views

How do you create a 2D random walk? [duplicate]

I've been trying to create a 2D random walk process for my project. The question is as follows, Create a 2-dimensional random walk process where the walker can move up, down, left, or right. The ...
2
votes
1answer
207 views

How to implement a Von Neumann neighborhood algorithm to random matrices/grids?

I'm trying to generate square grid templates to drill holes on a plate for a fragmentation experiment. The first part of the experiment I used the program below to generate uniformly random sites for ...
2
votes
1answer
79 views

How to pick a random points in higher dimensional parametric regions?

I am using a simple code to pick points randomly (uniformly) from a parametric region. This seems to work perfectly with 2D and 3D regions. For instance ...
1
vote
1answer
314 views

Can I use complex Gaussian random variables in Mathematica?

I have been looking for complex Gaussian random variables and Mathematica, however, I haven't found anything on this topic. Could someone, please, let me know if it is possible to find for example ...
0
votes
1answer
61 views

How to get a single evaluation of RandomReal in a Block

I want to generate (and eventually sample) a sine wave with a random frequency in the range [½, 1] (i.e. capture somewhere between half and one period of the waveform over the domain [0,1]). The two ...
2
votes
1answer
186 views

Create a random polymer chain

I want to create a polymer chain (in 2D) of a given length such that: 1. First monomer is at {0,0} 2. All other monomers are in the positive x half-plane 3. The ...
1
vote
0answers
46 views

RandomVariate without zero

I want to get 10 random numbers drawn from a Poisson distribution with mean 1. But I do not want to include 0 in this. When I do ...
0
votes
1answer
652 views

Using Random walk on a region [duplicate]

I want to simulate a random walk on two dimension equation using module. Checked the input so the path works ...
0
votes
0answers
43 views

How to carry out a different function based on weighted probabilities

I am looking to carry out a function based on weighted probabilities I have looked at using If[] and random numbers but ...
1
vote
1answer
52 views

Pick single random value from WhiteNoiseProcess

I have the following: m = 6.137*10^-13; k = 1.5*m; stddev = Sqrt[2*k]*Sqrt[m]; whiteNoise = WhiteNoiseProcess[stddev] How can I produce a function that gives me ...
3
votes
1answer
80 views

Generation of Binary number from some distribution function

In mathematica, RandomInteger[] generates binary numbers (0 or 1) with equal probablity (uniform distribution). If I wish to generate the binary numbers with ...

1 2
3
4 5
14