Questions tagged [random]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
32 views

One Function of Two Random Variable

I wonder how to implement below derivation in wolfram mathematica. I want to see integrate results like below picture. Can you help. I used "TransformedDistribution" but it shows only distribution ...
1
vote
0answers
23 views

What does this statement about congruential randomness mean in the documentation?

Reading through the random number generator guide on wolfram, under the methods section for the congruential method, it talks about the “Bits” option. Could someone explain what this means to me? I ...
0
votes
2answers
69 views

How to generated random waves

I want to generate a set of $N$ random waves, where the wave vector and phase are random numbers, this is my code ...
2
votes
1answer
104 views

Evaluate a parametric function dependent on a random number of parameters

This is a question related to the evaluation of a parametric function dependent on a random number of parameters. Consider a "blackBox" that returns a parametric function dependent on time (t) and, ...
10
votes
3answers
1k views

Efficiently finding furthest two nodes in a graph

I am trying to learn how in an efficient way can one find the diameter of a random graph, that is, the longest shortest path, and its corresponding end-nodes. The direct built-in function ...
0
votes
0answers
23 views

Optimizing and Parallel Computing for Large Dyadic Intervals

I need help with the efficiency of my code i.e. less time so I can compute for large range of values. My function n[x] takes in a number x and outputs the ...
5
votes
4answers
219 views

Manipulate a list: replace random position of a specific integer n times by 0

I have this matrix with 3 sublists: d = {{1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0}, {0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1}, {0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0}}; For ...
6
votes
2answers
656 views

How can I shorten the calculation time effectively?

I try to do a big simulation like below. (However, I do not change the sizes I want to 10 ^ 5, 10 ^ 7, 10 ^ 9.) ...
8
votes
3answers
845 views

Better random (unique) file name

In order to avoid conflict with file names produced by some code running in multiple instances of Mathematica I append the date and a random string at the end hoping to create a unique filename. The ...
1
vote
2answers
43 views

Question About Sampling from Conditional Distribution Created from Approximated Distribution

First, set the data and prepare the conditional distribution. pxy is joint distribution of Random Variable x and...
6
votes
4answers
840 views

RandomInteger with equal number of 1 and -1

I want to generate a list of random integers with only three values 1,0,-1. I know it can be done through RandomInteger[{-1, 1}, n]. How can I impose constraint on this list so that every integers in ...
4
votes
5answers
159 views

Generate random non-zero “island” in matrix of zeros

I'm trying to write a code which will generate a 3 dimensional array of 0s, then pick some random location in the array, and subsequently expand contiguously to random neighboring sites until a set of ...
3
votes
1answer
48 views

How to get a list of all known classes?

I'd like a function that returns a stringified entity at random. I can't seem to find a full list of classes from which to sample:
9
votes
5answers
1k views

How to generate random points without duplication?

In generating a list of random 2D integral coordinates e.g. {{u1,v1}, {u2,v2}, {u3,v3},...}, how can one write a condition specifying that no point is repeated, i.e ...
2
votes
1answer
27 views

Help with evaluation of the differential of a BSplineFunction?

It can be useful to generate a smooth random function over $[-L,L]$ with BSplineFunction: ...
5
votes
1answer
48 views

RandomPoint returns compiler errors on RegionIntersection of two Meshs?

Consider the intersection of two ConvexHullMesh's, m1 and m2. ...
3
votes
0answers
85 views

Parallel evaluation of RandomVariate for an InterpolatingFunction

I need to generate a lot of point according to a given distribution. I don't have an analytic form of this distribution so I am using an InterpolatingFunction of ~100 points computed numerically. I ...
3
votes
2answers
501 views

Generating random, non-repeating points on the plane

The problem is to generate random points on the plane that are unique (i.e. no repetition of a point). The following won't work because of repetition: ...
3
votes
0answers
62 views

Why does SeedRandom with same seed used twice produce such different results?

I have occasionally used RandomSeed[100] twice in the code and noticed behaviour that I don't understand. Consider: ...
7
votes
2answers
289 views

How can I generate a sin wave with power law noise?

I am interested in simulating a signal with different types of power law noise, as entitled in wikipedia, "Color of Noise". (The audio examples are pretty cool). Basically, white noise, which many ...
1
vote
0answers
109 views

RandomVariate with ProbabilityDistribution performs well in 10.0, but not in later versions

I have a custom probability distribution function and I want to generate numbers according to this PDF. Interestingly enough, this works without trouble on my MacBook with Mathematica 10.0, but when I ...
1
vote
1answer
82 views

Random sampling of a discrete distribution in NetGraph

Within a NetGraph I would like to use the output of a softmax layer, interpreted as a probability distribution, to sample a "next token". Since this is done inside an RNN structure, I cannot do this ...
4
votes
1answer
78 views

Improving Speed of Binomial and Multinomial Random Draws

A number of users have discussed the speed of Random number generation in Mathematica. The Binomial and Multinomial random number generators in Mathematica are fast if multiple draws are needed for ...
1
vote
1answer
110 views

Generate a uniform distribution over an $n$-simplex employing quasi-random low-discrepancy points

This post is intended in a similar direction to an earlier one Can I use Compile to speed up InverseCDF? . I now wish to generate uniform points in an $n$-simplex (specifically $n=8$), making use of ...
1
vote
1answer
67 views

RandomReal in combination with NormalDistribution [closed]

I am normally not working with Mathematica, but I have to understand a code written in i! Can some body say what the arguments and parameters of code below say? ...
1
vote
1answer
45 views

Parametric Ito Process

Is it possible to make a parametric ItoProcess ? I'd like to write that equation : ...
1
vote
1answer
38 views

Ito Process with Piecewise

I have the following ItoProcess : ...
0
votes
0answers
29 views

Computing the same stochastic ODE many times but with different random seeds

I have this stochastic ODE, where I'm using ParametricNDSolve and WhenEvents : ...
1
vote
0answers
61 views

Noise covariance matrix

I am trying to find the noise covariance matrix of a random vector $\mathbf{x}$ with itself. The elements of this vector represent image pixels and are treated as random variables i.e, $\mathbf{x}=\{...
1
vote
1answer
74 views

Drawing from InverseWishartMatrixDistribution. A machine precision error?

I'm drawing from the Inverse-Wishart Distribution, but I got the following error message: ...
1
vote
2answers
82 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
513 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
69 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
2answers
296 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
449 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
72 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
153 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
69 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
433 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? ...
19
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
50 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 ...
9
votes
2answers
120 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
123 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: ...
3
votes
4answers
614 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 ...
6
votes
2answers
278 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
109 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
82 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
82 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
360 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: ...