Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [random-generation]

The act of generating a sequence of numbers or symbols randomly, or (almost always) pseudo-randomly; i.e., with lack of any predictability or pattern.

2
votes
0answers
18 views

wigner semi-circle distribution random numbers generation

I am trying to generate random numbers in Wigner semi-circle distribution. Since this one does not have the analytical solution for the inverse function of the pdf. I wonder if anyone familiar with a ...
1
vote
1answer
41 views

Generating multivariate normal random variables only using unif

How can I generate n multivariate normal random variables only using the runif function (with mu and sigma). I know how to use box muller transformation, but not sure where to go from there once ...
1
vote
1answer
33 views

Books for self-learning about statistic Simulation?

Preferably an introductory book, i.e. for undergrad (or notes or something like that) that explains concepts with detail and with lots of examples, without losing the formality. That covers the ...
1
vote
1answer
14 views

Randomly choosing objects from a set of objects - guarantee all objects are picked at least once?

I got into a debate with someone in class over an experiment that was claimed to be randomized. The experiment was such that there is a bucket of distinct objects, and objects were being "randomly" (...
0
votes
0answers
143 views

Simulate data that arise from mediation with specified conditions

I am looking to create a function that simulates data arising from a mediation process, where a predictor (X) has an indirect effect on the outcome (Y) through the mediator (M). I consulted the ...
1
vote
1answer
22 views

Random draw from a linear model

I'm building an individual-based model where one component includes increasing winter temperature over time (years). For each iteration of the model (say 1000 iterations that have 25 years each) I ...
2
votes
0answers
18 views

Probability of matches being random

We have a set of 576 samples that have been assayed to obtain some omics information (genomic/epigenomic). The 576 samples are mostly from unique individuals, but we have some samples for which the ...
3
votes
1answer
192 views

How does the Metropolis Algorithm “get off the ground”?

I'm thoroughly confused by the Metropolis Algorithm as defined in Casella and Berger's Statistical Inference. Namely, here's the definition (p.254): Let $Y \sim f_Y(y)$ and $V \sim f_V(v)$, where $...
2
votes
1answer
38 views

What property must a RNG have to be used in Monte Carlo simulations?

For example, every cryptographically secure pseudo-random number generator (CSPRNG) is required to satisfy the next-bit test and withstand "state compromise extensions". This makes me wonder what ...
0
votes
1answer
51 views

How to calculate number of solid color images on the screen of random pixel generator?

Is there a statistical formula/function to calculate number of basic geometric shapes on the displays of random pixel generator? Let's say we have a basic random pixel generator which has 10*10 ...
2
votes
0answers
38 views

How to find the distance confidence between the sum of random variables and a given target value?

Given a distribution $X$($E[X]$, $Var[X]$) and a target value T, I am wondering whether there is a bound on $P(|\sum_{i=1}^{i=N}X_i - T| < \epsilon)$. For example, $P(|\sum_{i=1}^{i=N}X_i - T| &...
0
votes
1answer
23 views

Permutations, shuffling WITHIN but not BETWEEN groups [closed]

In R, I need to make 100 repeat random permutations of group orders, keeping the composition and sizes of groups the same, but the order within the groups needs to be randomly shuffled (100 times) By ...
0
votes
0answers
16 views

How can I map a Gaussian vector according to an equation that has a spatial autocorrelation function?

I have the following function: $E(x,z)=30-0.5z+12.5\frac{e^{Y(x,z)}-e^{0.5}}{\sqrt{e^2-e}}$ I want to run some Monte Carlo simulations and at each simulation I have to generate values for $E$ at ...
0
votes
0answers
30 views

Statistical Reasoning of Noise Images on Random Pixel Generator

http://www.pixelmonkeys.org/#theory It is always explained that even billions of images are generated per second, it is almost impossible to see a natural image ( whether it is clear or distorted as ...
0
votes
1answer
65 views

Simulate from a mixture of two beta distribution [closed]

I have this distribution : $X \sim 0.75\mathcal{B}e(\alpha_{X_1}=1,\beta_{X_1}=3)+0.25\mathcal{B}e(\alpha_{X_2}=5,\beta_{X_2}=1.75)$ where the density function is given from this function: ...
19
votes
3answers
3k views

Finding a way to simulate random numbers for this distribution

I am trying to write a program in R that simulates pseudo random numbers from a distribution with the cumulative distribution function: $$F(x)= 1-\exp \left(-ax-\frac{b}{p+1}x^{p+1}\right), \quad x \...
1
vote
2answers
33 views

Normal distributed random variables with constraint?

Consider $n$ random variables $X_i$ with $i=1,2,...,n$, each drawing values from identical normal distributions with mean $\mu=0$ and standard deviation $\sigma=const.$ so that expectation values are $...
2
votes
0answers
26 views

How to generate samples from joint distribution of normal and logistic with R?

How to generate triple data $(Y,R,X)$ with R code satisfying following restrictions: $X \sim N(0,1)$, $R$ is binary and $P(r=1\mid y=0,x) = expit(\alpha_0+\alpha_1 x)$. $Y$ is continuous and $Y\mid r=...
1
vote
1answer
15 views

Is there a term for a random sequence of integers with every consecutive pair in the sequence being unequal?

I'm trying to generate a random sequence of integers whereby no two consecutive values are equal to each other. This sequence is meant to simulate changes in state only. Is there some term or concept ...
6
votes
1answer
355 views

How to generate samples of Poisson-Lognormal distribution

I would like to compute samples of the number of product purchased in a supermarket. I want to model it with a mixed Poisson lognormal distribution. Items purchased $x$ of a given consumer follow a ...
2
votes
0answers
31 views

Generating Correlated Random Variables following Weibull Distribution

I am working on analyzing power generation from geographically distributed wind farms. I have wind speed data that have been collected at multiple locations, but the measurement periods for different ...
1
vote
0answers
115 views

How to sample from a multivariate uniform distribution with constrained sum [closed]

Problem description: Let say that we have the following 4 uniform distributions: $u_1$~$U_1(-1, 1), u_2$~$U_2(0, 2)$, $u_3$~$U_3(0, 0.2)$ and $u$~$U[U_1, U_2, U_3]$ subject to $u_1 + u_2 + u_3 = 1$. ...
1
vote
1answer
55 views

How to generate increasing (then decreasing) numbers with variance R [closed]

I have to generate numbers which increase and decrease, with variance in them. Exactly like the following image. I have tried rnorm but it generates random numbers which do not necessarily increase, ...
2
votes
1answer
60 views

How to generate random variables which are correlated and yet marginally identically distributed? [closed]

I am wondering if there is a process to which we can generate random variables where there is a correlation structure between them, yet they are still marginally identically distributed? One idea that ...
1
vote
0answers
28 views

How to simulate random correlation matrix containing off diagonal structures

I want to simulate a correlation matrix which has some off-diagonal structures and also should have some hierarchical structures. For simulating correlation matrices which contain hierarchical ...
0
votes
0answers
32 views

Different training results on different machines?

I'm running the exact same script (Python, TF and Keras) on my Macbook and on a DGX Server. I've tried once to verify if I can get the exact same result on both machines by fixing every seed of ...
1
vote
0answers
59 views

Simulate correlation matrix using a given structure

I want to generate correlation matrix such that it follows the below structure $$\Sigma = B \Lambda B^T $$ where $\Lambda$ is a diagonal matrix containing positive elements, $\Sigma \in R^{n \times n}...
2
votes
1answer
36 views

Why random numbers from fitted distribution do not have the same distribution as the sample data?

I have a data set and I would like to fit a t distribution on it. I use R or Python to feed into my data, and I get the degrees of freedom, the location and the scale parameters. After that, I ...
2
votes
1answer
87 views

Correlated random variables from mixture distributions

Let I have three random variables whose density is a mixture of two Normals with these parameters: $\mu_{1,1}=6.8$, $\mu_{1,2}=6.95$, $\sigma_{1,1}=0.065$, $\sigma_{1,2}=0.055$ and $\alpha_{1}=0.4$ $\...
1
vote
0answers
25 views

Is there a known PRNG that passes TestU01's BigCrunch but fails any test in NIST 800-22?

In other words, does TestU01 incorporate all statistical tests by NIST 800-22?
1
vote
0answers
44 views

A question about ``frequency of p-values''

In NIST 800-22, a battery of tests for rejecting a random number generator, they present their results with 10 columns expressing the frequency of p-values (section 5.7, interpretation of results, ...
6
votes
2answers
1k views

What is the state of the art in statistics tests for distinguishing good from bad random number generators?

There are many packages out there. In particular, PractRand gives out an opinion on a number of them, but it's only an opinion. Is there conventional wisdom about which set of set of statistics ...
1
vote
0answers
49 views

Random (?) number generation in R using sample() always returning the same result [closed]

I am writing an R script (using RStudio on Ubuntu 18.04), and at a certain point I need to randomly pick (with no replacement) 123 random numbers between 1 and 1040. I do this with: ...
3
votes
3answers
237 views

How do I use random seed appropriately?

I am writing a paper where I will analyze 6 designs. Responses for each design can be sampled from the main dataset. My question is that do I set 1 random seed for each sampling or 1 random seed for ...
12
votes
1answer
241 views

How to sample uniformly from the surface of a hyper-ellipsoid (constant Mahalanobis distance)?

In a real-valued multivariate case, is there a way to uniformly sample the points from the surface where the Mahalanobis distance from the mean of the is a constant? EDIT: This just boils down to ...
2
votes
1answer
114 views

Why are there different statistics tests in NIST SP 800-90B and NIST SP 800-22? [closed]

NIST SP 800-22 (published in 2010) lists out some statistical tests for telling good random bit generators from bad ones. NIST SP 800-90B (published in 2018) has apparently the same purpose but lists ...
0
votes
1answer
58 views

I like to generate correlated variables with a existing variable in R [duplicate]

In R, I like to create a set of variables that are correlated with a given variable.I scanned related questions but failed to find the same issue i have. Here is instance. ...
0
votes
0answers
36 views

Generate rank-order correlated permutations of sequence

I am seeking an algorithm with two inputs and one output. As the first input, consider any sorted finite sequence $s_1, s_2, ..., s_n$. The second input is a rank-order correlation parameter $\rho\in ...
1
vote
1answer
40 views

How do I sample arbitrary probability mass functions? (Archimedean Copula)

I'm trying to use an algorithm (Marshall, Olkin) for exchangable archimedean Copula to generate realizations of multivariate probability distributions. One step includes sampling V which is F ...
-1
votes
2answers
318 views

Why atmospheric noise is considered the only reliable source for generating “pure random numbers”?

When we say that something is random, it simply implies that the occurrence under observation does not have any cause or at least that cause cannot be determined beforehand in layman's language. For a ...
3
votes
1answer
76 views

Getting more time series data

I am trying to do time series forecasting following this [1] paper. My data is represented by the total CPU load of a computer as my time series (one data point per second). Secondary features are ...
2
votes
1answer
596 views

Sampling from a categorical distribution

I am confused by these lines of code: https://github.com/openai/maddpg/blob/master/maddpg/common/distributions.py#L174 ...
8
votes
1answer
218 views

Generate identically distributed dependent normal random numbers with prespecified sum

How do I generate $n$ identically distributed but not independent normal random numbers such that their sum falls within a prespecified interval $[a,b]$ with probability $p$? (This question is ...
4
votes
2answers
166 views

Random process not so random after all (deterministic)

I would like to show (demonstrate by simulation) a random process that turns out after $i$ interactions to be deterministic, i.e. ends at predefined value (roughly) known at time $t=1$. Conditions ...
1
vote
1answer
36 views

Can/should one generate Ginibre ensembles of random matrices using low-discrepancy normal variates--and if so. how?

I've been generating (via Mathematica) series of $4 \times 4$ "random density matrices with respect to Bures (minimal monotone) measure" https://arxiv.org/abs/0909.5094 [eq. (24)] and testing certain ...
7
votes
2answers
276 views

Efficient random generation from truncated Laplace distribution

We have several ways of drawing random samples from Laplace distribution. Is there any efficient way of sampling from left truncated Laplace distribution? Inverse transform sampling is an obvious ...
3
votes
2answers
251 views

Looking to see if random sample is uniform or not

I've been tracking data and I am looking to see if it is truly uniformly random. The scenario is there can be a grid of 35 colour tiles with 5 different colours (Blue, Green, Purple, Red and Yellow). ...
3
votes
1answer
202 views

Performance of Ridge and Lasso Regression depend on set.seed?

I try to do a ridge and lasso regression for out of sample predictions. The optimal lambda is chosed via cross validation. I run my results for different seeds in R. And depending on the seed i get a ...
0
votes
0answers
8 views

Buffer needed on random vectors to have a desired distribution

I was wondering while reading about the curse of dimensionality, how many vectors in d dimensions, I would need to generate before I would be able to "accurately" deduce what distribution I have. ...
4
votes
2answers
471 views

Can Bernoulli random variables be used to approximate more than just the normal distribution?

Most statistics students are familiar with the normal approximation of the binomial distribution. And since binomial distributions are created from sums of Bernoulli random variables, it would follow ...