Stack Exchange Network

Stack Exchange network consists of 174 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.

0
votes
0answers
24 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
35 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
2k 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
28 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
22 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
258 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
20 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
44 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
51 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
56 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
25 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
30 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
50 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
35 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
65 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
22 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
46 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
141 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
215 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
83 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
43 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
29 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
37 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
203 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
70 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
366 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 ...
7
votes
1answer
208 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
163 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
34 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 ...
6
votes
2answers
248 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
250 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
127 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
7 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
326 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 ...
56
votes
11answers
8k views

Brain teaser: How to generate 7 integers with equal probability using a biased coin that has a pr(head) = p?

This is a question I found on Glassdoor: How does one generate 7 integers with equal probability using a coin that has a $\mathbb{Pr}(\text{Head}) = p\in(0,1)$? Basically, you have a coin that may or ...
2
votes
2answers
163 views

Log-normal density function using rlnorm() in R

I tried to draw a log-normal density function by generating random numbers in R. However, the function is not working how I think it should. I draw two similar distribution using two different sample ...
22
votes
3answers
5k views

What exactly is a seed in a random number generator?

I tried some usual google search etc. but most of the answers I find are either somewhat ambiguous or language/library specific such as Python or C++ stdlib.h etc. ...
0
votes
1answer
58 views

Is there a simple way to randomly select a sub-set of case from a larger data set based on a specified unit-size?

I have a very large data set consisting of individual cases. Each individual case is associated with a unit-level id number indicating the group to which the individual case belongs to. So, there can ...
6
votes
1answer
80 views

Randomly choose between numbers that yields a specific amount of binary 1's

I want to randomly choose between any decimal numbers that - when converted to binary numbers - will produce the same amount of binary 1's within a total of 16 bits. It doesn't matter which bits that ...
3
votes
1answer
98 views

How to generate a random draw from the joint posterior density after MCMC has converged?

Consider a posterior density that involves two parameters: $\beta_1$ and $\beta_2$ given by $f(\beta)$ where $\beta = [\beta_1, \beta_2]^T$. We run a MCMC sampler to sample from the posterior and ...
5
votes
0answers
107 views

Good choices of PRNG for uniform circular (directional) data?

I'm planning to simulate iid one-dim variates with continuous uniform distribution on a normalized circle (which circumference is $1$ instead of $2\pi$). Namely, a sample consists of $n$ points ...
-4
votes
2answers
573 views

Sample multivariate PDF from KDE with different norm [closed]

I am using KDE with a modified metric for the distance. The PDF is as expected (see below: color is the probability and the dot is the point used to fit the KDE). But due to the new metric, I cannot ...
0
votes
0answers
42 views

Generating complex controlled image data

In order to demonstrate properties of statistical models it is often useful to generate data, which is messy, but messy in a controlled way which is well-understood by the generator. For example, to ...
0
votes
1answer
16 views

Random number selection from array vs rounding off selected random number

Here is the thought experiment . Objective : I need to select a random number in the search space between (1.00 and 4:00) Case Scenarios Use a pseudo-random number generator to identify number ...
0
votes
1answer
66 views

Generate sequence of random numbers with defined proximity

I need to generate a sequence of random numbers in some range (for example [0; 30,000,000]). There is an additional condition: About 85% of numbers must have a neighbour in distance not greater than ...
6
votes
1answer
232 views

a fast uniform order statistic generator [closed]

Can someone provide me with the mathematical expression for this code/function as a fast way to generate $n$ sorted $U[0,1]$ random numbers: ...
0
votes
1answer
69 views

Is there any relationship between random numbers sampled from some continuous distribution D and the quantile function of D?

I've noticed that when I sample n numbers from a continuous distribution D, sort them, and plot against the quantile function of D, both curves seem very similar. I've tried this for a few ...