Questions tagged [random]

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

Filter by
Sorted by
Tagged with
1
vote
2answers
191 views

Multiple unique random samples?

I'm trying to produce $n$ random samples from a list, but not all samples, and I'd like the samples to not repeat in the same execution of the command. If I'm not mistaken, something like ...
4
votes
5answers
1k views

How to generate binary array whose elements with values 1 are randomly drawn

I am trying to generate a binary matrix (whose elements are 0 or 1) of dimension 20x20. To do this, I want to supply as input the number of matrix elements that will take value 1. After, I want to ...
0
votes
1answer
126 views

Autocorrelated random field generation

Problem is related with my other question So, generate exponentially correlated row $π‘₯_{0,0},π‘₯_{1,0}...π‘₯_{𝑛,0}$ and starting from π‘₯0,0 there will be a correlated column $π‘₯_{0,1},π‘₯_{0,2}...π‘₯_{...
5
votes
3answers
404 views

Finding the dangling free part of a cluster connecting two nodes

I am trying to learn how to use Mathematica for analyzing graphs, more specifically in the context of connectivity and percolation. For the sample graph that I have included in this post, we have a ...
6
votes
2answers
742 views

Graphing random points on the XY-plane

I am trying to generate around 10-20 points on the xy- plane in the domain $[-10,10]\times[-10,10]$ (in 3D) and I am having trouble. I want to draw the plane in 3D, graph the random (they do not have ...
0
votes
1answer
114 views

Monte Carlo simulation using modified rejection technique

Plot the probability density function $\qquad w(x)=(1/(1+x^2))(1/x^{0.5})$ for $(0 < x < 1)$ Make up the subroutine flowchart to get the random numbers $x$, using the modified ...
2
votes
4answers
244 views

How to generate a matrix with certain conditions

I want to generate a $n \times n$ matrix. I want the diagonal entries to be all 0 I want a random choice of matrix elements with 0 or 1. The probability of having a 1 as a matrix element is $1/m$ and ...
2
votes
1answer
81 views

Perpendicular chord lengths from the boundary points of an arbitary 2D shape

Let's generate an arbitrary convex domain with smooth boundaries: Graphics[BSplineCurve[{{1, 4}, {5, 3}, {9, 4}, {5, 5}, {8, 7}}, SplineClosed -> True]] I'...
11
votes
2answers
452 views

On random numbers extracted from NormalDistribution by two different methods under the same seed

I've encountered the following situation within various trials. Why does such a difference arise between bulk sampling and one-by-one sampling? ...
5
votes
1answer
498 views

Trying to compute the heat capacity for the 2D-Ising model

I'm trying compute the heat capacity $C_v$ out of my simulation for the 2D-Ising model which is given by $C_v = \frac{\langle E^2 \rangle - \langle E \rangle^2}{T^2N^2}$ ($E$: Energy, $T$: ...
20
votes
5answers
1k views

Sisyphus Random Walk

A Sisyphus Random Walk evolves as follows: With probability (r) you advance the position of the walker by +1. With probability (1-r) the walker resets at x0 = 0. To simulate the probability of reset ...
1
vote
1answer
54 views

How to take a point randomly from a region [duplicate]

I want to take some points randomly by the limits above, I had try to use FindInstance method but it always out (0,0) ...
7
votes
5answers
1k views

Survival Probability for Random Walks

The Survival Probability for a walker starting at the origin is defined as the probability that the walker stays positive through n steps. Thanks to the Sparre-Andersen Theorem I know this PDF is ...
10
votes
2answers
164 views

Controlling the randomness of DropoutLayer

How can I control the randomness of DropoutLayer in order to get the same result after each execution? For example: ...
5
votes
2answers
250 views

Obtain the current value of the seed used by the random number generator

I would like to be able to do something like the following pseudocode: ...
0
votes
2answers
2k views

Generate Random Symmetric positive definite matrix

Is there any way to create a random symmetric positive definite matrix ?
3
votes
4answers
1k views

Random Six Character Strings Without Collisions

I want to generate a random list of six characters that only contain characters from "0...9" and "A...Z". For this I can define ...
7
votes
2answers
325 views

Record Statistics for Discrete Random Walks

I code a random walk of length 100 drawn from a LaplaceDistribution: Accumulate[RandomVariate[LaplaceDistribution[0, 1], 10000]] I am having trouble counting the ...
1
vote
2answers
125 views

Sampling data from numerical values of density distribution of nucleons

How could i sample my data which follows distribution if i have only numerical values of density distribution as an example data attached as in picture I tried but do not know how to do it. The data:...
0
votes
2answers
91 views

2d-RandomWalks with N steps and fixed distance between first and last point

community, I'm trying to figure out a way how to create a 2d list simulating a N-Step-Randomwalk with a fixed distance between first and last point. I already got the RandomWalk with the step size 1: ...
5
votes
0answers
99 views

Random number generation within Compile and Parallelization->True

According to this thread RandomChoice is a compilable function. I use it to generate random numbers in a compiled function with parallelization enabled. I wrote ...
4
votes
6answers
597 views

Randomly distribute numbers to lists

I have 4 empty lists. I would like to randomly distribute numbers from 1 to 10 to these 4 empty lists. How can I add integers to lists randomly? For example: ...
3
votes
3answers
447 views

Sum of Random Integers

I am trying to get a list of numbers with at least 1000 sums as possible, using random numbers from 1 to 10. But I don't want to get blank list output. How can I only get a list of numbers greater ...
0
votes
3answers
40 views

How to create 2 lists of RandomIntegers based on condition?

How do i create 2 lists of RandomIntegers that are the same at certain points based on a condition. For example there are three lists: List A List B List C List C already exists. I am trying to ...
2
votes
0answers
105 views

How to match random number generator to R?

Although I know the algorithm that R is using for pseudo-random numbers I am unable to match the generation of random numbers. ...
3
votes
1answer
647 views

Generate a smooth random function (2D curve) with endpoints specification?

Here is a PDE example, adapted from Wolfram Documentation: ...
2
votes
1answer
68 views

Drawing random numbers from TransformedDistribution

Suppose I have created the following TransformedDistribution: ...
2
votes
0answers
104 views

How do decrease uncertainty of Monte-Carlo integration?

I have some function of many arguments and need to integrate it over the region given by the products of Heaviside theta functions. Namely, I write, say, ...
1
vote
1answer
300 views

How to select random number of elements from a list?

Assume that I have a list a = {1,2,3,4,5,6}; and I want to have a function that outputs a subset of the list such that with probability p=0.2 each element will ...
2
votes
1answer
94 views

Random points from an image using a BernoulliDistribution

I am a Mathematica newbie. I need to sample random points from an image which I have stored in a variable img as: ...
0
votes
1answer
208 views

Why does Monte Carlo integration underestimate my integral as integration range increases?

I'm having a huge problem with Monte Carlo integration. This simple example adequately shows the problem. ...
2
votes
1answer
50 views

Matrix Randomization

Is there a way to take a 20x20 array and replace 2 random parts of this array with a 2x2 matrix? I've tried rvalues = ConstantArray[r, {20, 20}]; to make the ...
0
votes
1answer
122 views

Negative values with RandomVariate

I am using the following code to generate some random number from a custom distribution: ...
0
votes
1answer
50 views

Am I using RandomVaraite and ProbabilityDistribution correctly?

The following code does not produce an output on my Mma (version 11.3 for Windows) ...
7
votes
2answers
267 views

How can I get new random values with each blank in ReplaceAll?

Is there any way to get different values for different blanks with ReplaceAll[]? For example, I would like to do something like: ...
22
votes
3answers
2k views

Efficient way to simulate thousands of Markov chains

I am currently trying to simulate relaxation of a protein population while maintaining the stochastic properties of the system. For this, I used a Markov chain to describe the temporal evolution of ...
6
votes
3answers
236 views

How can I delete a random part of an expression?

I have the expression: Times[0.19157500241430547,Power[Plus[0.7235014213631388,k,Times[-1,Power[m,c]]],Times[g,z]]] Also represented as: ...
5
votes
3answers
195 views

Improving the run time of random walk simulation

One of our professors told us that during his thesis he used Mathematica in simulating it since it is about networks, I don't know how he did it but all I know is he said it took about two weeks to ...
4
votes
3answers
572 views

Construct Distribution Histogram From Random Variable

Given a Beta Random Variable $X$ with parameters $\alpha, \beta$ and a positive constant $n$, suppose I am interested in the distribution of: $$Y:=\lfloor nX\rfloor$$ Suppose I want a histogram ...
2
votes
1answer
80 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?
12
votes
5answers
753 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.
5
votes
1answer
294 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: ...
3
votes
0answers
160 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 ...
4
votes
2answers
155 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
92 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
39 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 ...
8
votes
2answers
2k 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
114 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
435 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 2 3
4
5
…
16