# 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.

783 questions
Filter by
Sorted by
Tagged with
1 vote
30 views

### Generating highly non-independent random samples

I'm testing performance of statistical tests in the face of non-independent data and I'd like to generate random data where I know the underlying statistical distribution. The easiest way to do it is ...
• 178
1 vote
21 views

### Quasi-random number sequence that is unbiased on the unit interval

I am trying to use the Halton sequence for a quasi-Monte Carlo method in two dimensions. However, a problem I am running into is that the mean of the sequence is always less than one-half (except for ...
• 431
1 vote
26 views

### Choosing a unique visitor on the fly

I've been thinking of this as the "Prize of the Week" problem. Suppose you run a shop, and want to give out a prize once a week to someone making a randomly-selected purchase. You give out ...
• 111
23 views

### Does pattern in random seed for Pseudo random functions cause bias [duplicate]

I am using random forest in R, and for different test sets I'm using patterned seeds in the sample function. For one test set I use 1234, for the next 2345, the next 3456. I suspect it is unlikely, ...
20 views

### Why doesn't my numpy code for generating correlated, normally distributed variables preserve the covariance?

I'm trying to generate random variables whose correlation matches some existing data. My coding skills are good, my statistics, not so much... I'm trying to follow this this answer. I know that... ....
1 vote
23 views

### How to accurately determine if a random method is indeed random? [duplicate]

I wanted to do a project where I measured how random the native RNGs are in various programming languages. How can I objectively measure my results? Also, if you run a random number generate say 100 ...
• 131
1 vote
115 views

### Tightness of rejection sampling

Hello. I'm studying the Monte Carlo Statistical Method textbook by Robert and Casella. I have a question about exercise problem 30 in Chapter 2. I've already solved parts (a)-(c), but I'm having ...
• 31
30 views

### Generating Distributions From Random Number Generators

Background I am working on developing a R package that focuses on implementation of pseudo-Random Number Generators (pRNGs) from scratch. To date I have successfully programmed a Linear Congruential ...
• 173
49 views

### How to shuffle and deal with constraints?

I'm playing a 4-player game of cards. My opponents are called A, B and C. At the beginning of the game, each player has been dealt a hand of cards out of a deck containing 4 suits of cards: Black, Red,...
• 21
81 views

### Drawing randomly from range - is a uniform distribution possible?

The specific task is to draw 5 random samples in the range of 0 to 90 with a minimum disstance of 7 between each sample. I performed 1 million runs with respect to the conditions. The first image ...
12 views

### Determining Optimal Output Length for Algorithmic Pseudo-Randomness with Unique Mapping for Inputs of Size X

I am constructing an algorithm where it should map every input to a different output and the output bits should be statistically random (that is when put into randomness test suites (like NIST), it ...
275 views

### Am I right that the Bonferroni correction does NOT apply to randomness testing?

There are statistical test suites (below) that are commonly used to determine whether a sequence appears to be (pseudo) random. Some of these test suites have a few tests (ent/ent3000), whilst others ...
• 666
452 views

### Generate multivariate distributions of lognormal and normal distribution in python

I need to generate random numbers from 3 correlated distributions. First two of them are lognormal and the final one is normal, i.e. for X, ...
• 163
1 vote
20 views

### Can inverse sampling method be adapted to random vectors?

This might be a very basic question, but it seems that in all the examples I've seen, the inverse sampling method (i.e., input uniform RV into the inverse of CDF of desired PDF/probability ...
• 1,590
1 vote
44 views

### Unbiased estimate of mean test score of pupils in a country (sampling frame of schools is avaible only)

My primary goal is to get unbiased estimate of mean test score of every pupil in a country. I have no sampling frame of all pupils to randomly sample from. But I have a sampling frame for every school....
• 101
1 vote
55 views

### Does an algorithm exist that generate copula when marginal distributions are available and stable distributed and correlation is not simple?

I have simulated data of a 4-dimensional random variable $(X_1,X_2,X_3,X_4)$. The individual pdfs of these random variables, i.e., $X_i$ where $i\in\{1,2,3,4\}$ turns out to be stable distributed with ...
• 167
95 views

### Uniformly sampling surface of an ellipsoid using multivariate Gaussian

Sampling uniformly from the surface of an ellipsoid (in the sense of $\mu(dA) = \frac{1}{A}$) seems very nontrivial: How to sample uniformly from the surface of a hyper-ellipsoid (constant ...
82 views

### Generating a random number with CDF $P(X \leq c) = 1-1/c$ in the interval $(1, + \infty)$. using uniform distribution

I have a uniform number generator in ($0, 1).$ I want to generate a random number with CDF $P(X \leq c) = 1-1/c$ in the interval $(1, + \infty)$. I know I should apply the inverse of my function to ...
• 637
229 views

### Is there a law or theorem related to occurrence of an event with highest probability in a population with infinite size?

Assume, we have a key that appears in either of the three rooms randomly (red room, blue room, and green room). We have the following probability distribution: ...
• 25
64 views

### Random Walk and Moving Average for Stock Market Model

I model a stock price with a completely random walk: In each step I multiply the price with normal distributed random number with an mean of 1. Then I compute a signal, which is True if the moving ...
132 views

### Question about the inversion method for simulation of random variables [closed]

In the method called inversion we have : Let $U$ ~ unif(0,1) denote a uniform random variable on $(0,1)$. Then : $\mathbb{P}(F^{-1}(U))$ = $\mathbb{P}(U \leq F(x))=F(x)$ so $F^{-1}(U)$ has ...
• 103
32 views

### How does one sample from a gaussian distribution without a library? [duplicate]

I am looking to write a program that generates samples from a gaussian distribution with a certain mean and standard deviation. I am not allowed to use any library except a random number generator. Is ...
67 views

### Bootstrapping CI around variance ratio from random regression model

I am interested in the ratio of random slope variance from a random slope and intercept model. I fit the model using lme4 as ...
1 vote
25 views

### Generate numbers between 0 and N in a random order guaranteeing uniqueness with efficient memory cost [closed]

I'm trying to think of a method i could use to generate the random numbers between 0 and N in a random order and with uniqueness that would use the smallest footprint of memory at the beginning and ...
• 111
4k views

### How many numbers can I generate and be 90% sure that there are no duplicates?

Suppose I am generating random 4-digit numbers. Obviously there are 10,000 possible numbers, but the chances are I will get a duplicate long before I generate that many. Can anyone explain how I would ...
1k views

### Sampling from Gaussian Process

I am learning the Gaussian process and feel confused about how three lines were generated in Fig 2.2(A) in the book "Gaussian Process For Machine Learning". As described by the author: "...
1 vote
52 views

### Drawing numbers using the CDF

Say I have a (generally high-dimensional) random variable $X$ with known, continuous CDF $F(X)$. Is there a good algorithm for drawing values of $X$ that doesn't require that I calculate the joint ...
• 211
28 views

### Drawing random numbers with quadrature

In a comment on this question, the user 'probabilityislogic' says "No, not MCMC this thing! Quadrature this thing! only 2 parameters - quadrature is the "gold standard" for small ...
• 211
92 views

### Generating uniformly distributed particles on a $n$-dimensional flat torus or periodic hypercube [closed]

I am trying to generate evenly distributed particles in an $n$-dimensional flat torus or a periodic hypercube. I am not sure if any of this approaches suffices. Can you suggest alternative methods for ...
• 31
2k views

### How to generate from this distribution without inverse in R/Python?

I am working with a distribution with the following density: $$f(x) = - \frac{(\alpha+1)^2 x^\alpha \log(\beta x)}{1-(\alpha + 1)\log(\beta)}$$ and CDF \mathbb{P} (X \leq x) = \int_0^x - \frac{(\...
• 197
148 views

### Testing relationship between exponential and beta distributions using R

If X ~ Exp(3), Y ~ Exp(1) and h = X / (X + Y) then h ~ beta(1/3, 1) and E(h) = 1/4. But when I draw random deviates using the following R code, I find mean(h) ≈ 0.324 and the histogram doesn't ...
• 21
55 views

• 357
274 views

### Random number generator for non-central chi-squared with non-integer dimension

Does someone know of a random number generation algorithm for a non-central chi-squared distribution with a non-integer dimension? PS By algorithm, I am interested in the detailed procedure or ...
96 views

### Numerical Stability when Inverse CDF Sampling from Truncated Density

Let $f(x)$ be the pdf of a random variable that we want to truncate to the interval $[a,b]$ and then sample from it. Let $F(x)$ denote the corresponding cdf. We can use inverse cdf sampling and ...
• 700
1 vote
32 views

### Suppose $f: \mathbb{R}^n \to [0, 1]$ is known, how to sample $x \in \mathbb{R}^n$ such that $f(x)$ follows uniform distribution? [closed]

Suppose $f: \mathbb{R}^n \to \mathbb{R}$ is known, where evaluation and gradient computation is easy. How can I sample $x \in \mathbb{R}^n$ such that $f_x \in \mathbb{R}$ follows uniform distribution? ...
65 views

### How many toss a coin attempts required so the noise is always less than 1%?

I don't know what is it in statistic term, but I will say it the noise. Noise is defined as absolute difference between real percentage result after experiment and ideal probability. The question is ...