Skip to main content

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.

Filter by
Sorted by
Tagged with
1 vote
1 answer
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 ...
Hubert Kario's user avatar
1 vote
1 answer
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 ...
ischmidt20's user avatar
1 vote
0 answers
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 ...
Ralph Giles's user avatar
0 votes
0 answers
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, ...
Pierre Raynerd's user avatar
0 votes
0 answers
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... ....
MemoryWrangler's user avatar
1 vote
0 answers
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 ...
skarz's user avatar
  • 131
1 vote
0 answers
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 ...
urikokp's user avatar
  • 31
-1 votes
1 answer
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 ...
Bensstats's user avatar
  • 173
2 votes
0 answers
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,...
FlPI3Rd8's user avatar
0 votes
1 answer
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 ...
cupcake's user avatar
0 votes
0 answers
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 ...
user279163's user avatar
4 votes
2 answers
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 ...
Paul Uszak's user avatar
4 votes
3 answers
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, ...
Xu Shan's user avatar
  • 163
1 vote
0 answers
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 ...
Fraïssé's user avatar
  • 1,590
1 vote
0 answers
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....
Nothingman's user avatar
1 vote
1 answer
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 ...
Userhanu's user avatar
  • 167
3 votes
0 answers
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 ...
Master Yogi's user avatar
0 votes
1 answer
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 ...
AutisticRat's user avatar
2 votes
1 answer
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: ...
Breeze's user avatar
  • 25
0 votes
1 answer
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 ...
Ruediger Jungbeck's user avatar
0 votes
1 answer
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 ...
John john's user avatar
  • 103
0 votes
0 answers
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 ...
desert_ranger's user avatar
2 votes
1 answer
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 ...
stats-what's user avatar
1 vote
0 answers
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 ...
eljiwo's user avatar
  • 111
21 votes
2 answers
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 ...
Avrohom Yisroel's user avatar
3 votes
1 answer
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: "...
user3153824's user avatar
1 vote
1 answer
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 ...
Wilbur's user avatar
  • 211
2 votes
0 answers
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 ...
Wilbur's user avatar
  • 211
3 votes
0 answers
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 ...
Rober's user avatar
  • 31
12 votes
6 answers
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{(\...
Lucas cantu's user avatar
2 votes
1 answer
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 ...
rob's user avatar
  • 21
2 votes
1 answer
55 views

Sampling from a distribution function $g_{x}$ that will follow $f_{x}$

I am using acceptance-rejection sampling to sample random variable $x$ according to distribution $f(x)$. The steps I followed are First generated uniformly distributed random variable $x$ from 0 to $...
Prab's user avatar
  • 21
5 votes
2 answers
353 views

How to generate a standard normal distributed time-series with a given ACF

I want to generate a standard normal distributed time-series. In addition the ACF of my timeseries should match a desired ACF. I have given lags 1 to 30 with the corresponding ACF-values. For further ...
Christian's user avatar
2 votes
0 answers
34 views

Relaxed magic-square generator distribution

This question is about a magic square generator, "relaxed" because it's only about one vector (row) in the square independent of all other rows; the individual elements are continuous and ...
Reinderien's user avatar
8 votes
2 answers
365 views

Generating uniformly distributed random solutions of a linear equation

Given $n+1$ variables $p_0, p_1, \ldots, p_n$ defined over $\mathbb{R}^{+}$ so that $\sum_{i=0}^np_i=1$, and given a real number $1<x<n$, I want to generate random solutions of the equation so ...
ABu's user avatar
  • 381
10 votes
8 answers
2k views

How to generate uniform distributed samples with given auto-correlation function

As I mentioned in the question title, I want to generate specific uniformly distributed samples. I need them to model a real world scenario. For my real data, I estimated a function, which ...
Christian's user avatar
0 votes
1 answer
41 views

Control Chart: Nelson alternating rule

The Nelson rules for control charts describe patterns, which are "special" and need our attention. One of these rules is the "alternation rule". According to Nelson it is "...
Semoi's user avatar
  • 751
5 votes
1 answer
574 views

random number generation of truncated multivariate normal distribution

I want to generate random numbers from truncated multivariate normal distribution specified as follows: $ \begin{bmatrix} Y \\ X \end{bmatrix} \sim N \begin{pmatrix} \begin{bmatrix} \mu_Y \\ \mu_X \...
user0131's user avatar
  • 357
6 votes
1 answer
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 ...
user378619's user avatar
0 votes
0 answers
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 ...
yrx1702's user avatar
  • 700
1 vote
0 answers
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? ...
orematasaburo's user avatar
0 votes
0 answers
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 ...
Muhammad Ikhwan Perwira's user avatar
2 votes
1 answer
152 views

Generate two random correlation matrices which share equal correlations

My setting is, I want to simulate a data set in two conditions, e.g. control and disease. I want them to share mostly the same correlations except some should be different to simulate a "signal&...
Sinraw's user avatar
  • 21
1 vote
1 answer
146 views

Generating random variables from a mixture of Normal distributions and Exponential distribution using composition method

How can I sample from a mixture distribution in particular a mixture of Normal distributions and Exponential distribution in R using composition method? For instance if I want to sample from: $0.3\...
Tegig's user avatar
  • 39
1 vote
1 answer
211 views

Perfect sampling and inverse transform sampling

Firstly, looking at the discussion https://math.stackexchange.com/questions/241315/three-ideas-of-perfect-sampling, the term "perfect sampling" does not seem adequate, since there are ...
Ludwig's user avatar
  • 63
1 vote
1 answer
20 views

How can I find the k-th smallest element of my list of random numbers? [closed]

I have generated exponential random numbers using x <- rexp(1000,1) with set.seed(1). I can look at them using ...
math_undergrad_questions's user avatar
7 votes
2 answers
323 views

Element-wise comparisons of sorted subsets of random numbers yield nonrandom results

Say we have a random number generator. It generates 2000 numbers that we put in two arrays, 1000 numbers each. Like this (here shorter arrays used to illustrate the point): [4, 20, 5, 6] [7, 21, 3, 3] ...
user2669285's user avatar
12 votes
1 answer
679 views

What is B. D. Ripley's method of seeding the Mersenne-Twister RNG?

R's documentation behind ?runif states that the default RNG is "Mersenne-Twister": From Matsumoto and Nishimura (1998); code updated in 2002. A twisted ...
ColorStatistics's user avatar
2 votes
1 answer
462 views

Pseudo-dice probability distribution

Given the following data, is there an algorithmic way to generate a probability distribution? Data: min, max, and average results of "die". Known Trend: results will always be weighted ...
Learn34's user avatar
  • 21
3 votes
2 answers
109 views

Random sampling from a super level set

I have a random sampler from a region $X$. Suppose, I have a function $f: X \to \mathbb{R}$, where I can explicitly evaluate $f(x)$ and also obtain the gradient $\frac{\partial f}{\partial x}$ easily (...
orematasaburo's user avatar

1
2 3 4 5
16