Questions tagged [random]

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

Filter by
Sorted by
Tagged with
5
votes
2answers
219 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
142 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
137 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
72 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
206 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
49 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
158 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 ...
0
votes
0answers
82 views

Allow or force self-loops in a Random Graph with 'BarabasiAlbertGraphDistribution'?

While generating random graphs, I assumed that self loops were allowed in the BarabasiAlbertGraphDistribution, but after checking the adjacency matrix, and the plot ...
1
vote
0answers
43 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
249 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
33 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
51 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
63 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
vote
1answer
106 views

Plot the critical points of degree $d$ polynomials with zeros randomly chosen in given region

I wish to be able to scatter slightly (by at most some fixed $\varepsilon>0$) the zeros of a given complex polynomial $p(z)$ in a random way, and then see the effect on the critical points. For ...
1
vote
1answer
53 views

create one list from one list with random sample

I have a list, then I want to pick 2 elements (RandomSample[list,2]) put them in a new list (those two element will be one element in the new list, like list of ...
2
votes
1answer
77 views

Generating the cumulative distribution function (CDF) of a tuple made by RandomFunction

I use the RandomFunction to generate a continuous random function (trying to model a rough surface): ...
4
votes
2answers
227 views

Distribution of Function of Random Sum of Random Variables

Let $ S = \sum_{i=1}^n X_i$ where: Each $X_i$ is independently 3 or 9 (with equal probability), and The sample size $n$ is itself an independent random variable where $N \sim \text{NegativeBinomial}(...
0
votes
3answers
68 views

How to get a function within ConstantArray to evaluate for each list element?

Here is my code example: ConstantArray[RandomInteger[{1, 5}], 10] However as my output I get something like ...
3
votes
3answers
185 views

2D Random walk under specific boundary

I try to create the code so that from initial point (that I can set), code runs so that it performs random walk, yet it turns off once the point hits the wall. I tried this method however, I was not ...
0
votes
1answer
74 views

Run Block of Code in For Loop

Suppose I want to conduct an experiment 10,000 times in which a random sample of size $n=20$ from a beta distribution is collected and then the values of four different estimators are collected. At ...
2
votes
2answers
77 views

How to create ordered and custom formatted random matrices?

I'm trying to generate square grid templates to drill holes on a plate for a fragmentation experiment. I have three different problems that I'm not finding a way to solve using the documentation, they ...
3
votes
1answer
274 views

Simulate random sample from defined probability density function

Suppose I define a function in mathematica that has all of the properties of a valid probability density function. Would it be possible to have Mathematica simulate a random sample of a given size of ...
16
votes
1answer
157 views

RandomChoice output isn't packed

Why isn't the output of RandomChoice a packed array? For instance: RandomChoice[{.5, .2, .3} -> {1, 2, 3}, 10] Developer`PackedArrayQ @ % {1, 2, 3, 1, 3, 1, ...
8
votes
6answers
864 views

Efficient binarization of a list

I am generating a list of 1's, 2's, and 3's with different probabilities for each number. I then convert this list into three binarized lists, giving a list of the locations of each digit in the ...
1
vote
1answer
134 views

ItoProcess and/or RandomFunction numerical failure for coupled SDEs

I'm trying to simulate a physical system including noise using the ItoProcess command, the system is governed by two coupled differential equations. The potential ...
7
votes
2answers
221 views

matrix with chosen elements distributed in a random position

I would like to generate a matrix whose dimension is L^2 and whose entries can be only in a finite set but in random positions in the matrix. such as ...
1
vote
0answers
62 views

Dealing with Vector Outputs from ItoProcess, RandomProcess (Stochastic Differential Equations)

I'm modeling stochastic chemical kinetics and the ItoProcess[] function has served me well. I am trying to write an efficient code to analyze many (Paths) trajectories of several different reagents (...
2
votes
1answer
250 views

Plotting sine curves with different random noises

I would like to generate data in Mathematica that follows a sinusoidal curve. However, I would like to add a Gaussian noise to the curves so as to reproduce graphs ...
7
votes
2answers
192 views

Take random sample of paths in a graph

I have a directed graph with 51 nodes. I want to extract a (big) random sample of the possible paths from node $i$ to node $j$. I know that I can generate a list that contains all the paths with <...
0
votes
1answer
126 views

Improve random generation of matrices

My problem is too plenty of subtleties that a detailed explaination would be boring. I will try to state my problem in a more general way. I have a 5x5 matrix called $M$ which depends on several ...
1
vote
1answer
45 views

Calling function with random output twice

I would like to call a function, which creates some random output (let's say a random integer) in a single expression twice. A minimal example: ...
3
votes
3answers
78 views

SkewNormalDistribution with a mean value

Since it got incredibly good answers the last time i posted a question, i try it again! ;-) I programmed a chemical/physical simulation in mathematica, where i can use residence time distribution as ...
3
votes
4answers
445 views

Any built-in function for this code?

Is there any build in function or shorter version of this? Assume I have 3 reactions time and each reaction occurs randomly. Generate rand=RandomReal[] if rand<0....
3
votes
1answer
133 views

Unexpected behavior of ToBoundaryMesh and ToElementMesh

This question is about functions ToBoundaryMesh and ToElementMesh. I use both functions successively because I need information ...
4
votes
1answer
150 views

First order ODE with random force

I need to solve using first order Euler method some simple equation $ \frac{dc}{dt} +3 c = f(t) $ where $f(t)$ is random delta-correlated force: $<f(t_1)f(t_2)>=2A \delta(t_1-t_2)$ Searching ...
1
vote
3answers
111 views

Number of realizations in NExpectation, Method Monte Carlo

I have been looking in NExpectation about how large the sample size is when Mathematica performs Monte Carlo simulation. For example, if we write ...
9
votes
5answers
313 views

Probability a random triangle on a circle contains the origin

Another great video from 3Blue1Brown describes a neat proof (at about 5:45) that this has to be 25%. I wanted to do the experiment in Mathematica as a way of showing how exploring the problem ...
4
votes
0answers
114 views

Generating random interlocking regions (i.e. countries)

I am trying to subdivide a finite portion of the plane into a set of at least 20 or so random interlocking shapes, with the shape boundaries having a fractal dimension around that of borders between ...
12
votes
4answers
2k views

Building a Noisy Function

Here's a nice function with a nice plot: f[t_] := Exp[-Abs[t]] Sin[t]; Plot[f[t], {t, -10, 10}, PlotRange -> All] What I would like to do is to make it noisy.....
9
votes
3answers
675 views

Creating random configurations of spherocylinders or cylinders

About the setting: We have a 3D simulation box with side $l$ and our catesian coordinate system is set with its origin at the centre of the box. We have a number $N$ of spherocylinders of aspect ...
7
votes
2answers
1k views

Generate white noise in 2D

I am trying to generate a random (white noise) signal, as mentioned in the section Frequency Synthesis of Landscapes (and clouds) on this website. The problem I have is that I do not know if ...
1
vote
0answers
74 views

MultinormalDistribution not having the right mean [closed]

I am using the function MultinormalDistribution to generate a random vector using the following code: ...
7
votes
1answer
230 views

Generate random matrix where the entries in each column are drawn from a different range

I know that you can generate an $m\times n$ matrix of random numbers by RandomReal[range, {m, n}], where e.g. range = {0, 1}. ...
1
vote
0answers
78 views

Issue with RandomFunction and TimeSeriesModelFit in V11.2

I have a notebook which was working with V11 and now not working with V11.2. I have wind speed data with a regular timestep of 1hr. Taking a month : ...
3
votes
3answers
99 views

Average number of uniform variates needed for their sum to be $> 1$ should be $\approx e$

An interesting tweet from Fermat's Library proves that the average number of random values [0,1] that are needed to Total > 1 is about $e$ (2.718...). I don't get ...
28
votes
3answers
1k views

Implementing a planetary terrain generation algorithm

From this (now deleted) question I found this site where the author discusses a simple technique for random terrain generation on a sphere. The method discussed is as follows: start with a ...
1
vote
0answers
132 views

Parallelization of Monte Carlo numerical integration

I'm trying to parallelize some integral. What I do: I define integrand: ...
1
vote
1answer
103 views

Modeling Dependent Joint Distribution

I'm trying to model the joint pdf of (X,Y) from example 4.5.8 of the text Statistical Inference 2nd Edition, Casella, Berger (pg 199 of the pdf). Essentially, X ~ Uniform[0,1] Z ~ Unfiorm[0,1/10] Y ...
2
votes
1answer
95 views

How can I use WienerProcess with TimeSeriesForecast?

I created a TimeSeries from Date-Value-Pairs, which I imported from a .csv-File diffp = Import["path/difficultyp.csv", "Data"]; tsdiff = TimeSeries[diffp]; I ...
7
votes
5answers
571 views

Stop Mathematica from rounding the value

My task is simple. Calculate the average value for 10^7 dice throws using computer pseudo-random-number-generator. x := RandomInteger[{1, 6}] gives me one ...