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

727 questions
Filter by
Sorted by
Tagged with
18 views

### Right type of randomization / random allocation for low base rates

so I have a question on the correct "name" for the random-allocation to one of two treatment groups or one control group. We designed two interventions (readings material): one on ...
• 61
32 views

### Generating multivariate random variable with normal and exponential marginals

I have a collection of data points of the form $[U, V, X, Y]$, where $U$ ~ $N(\mu_1, \sigma_1)$; $V$ ~ $N(\mu_2, \sigma_2)$; $X$ ~ $exp(\lambda_1)$; and $Y$ ~ $exp(\lambda_2)$, and I am looking to ...
• 123
25 views

### Correlation matrix from pairwise correlations with specified structure

I need to simulate multivariate normal samples with a pre-specified correlation structure. The structure is such that the bigger the (GPS) distance between two points, the smaller the correlation (...
• 184
24 views

### How to weight probabilites of getting sampled depending on the frequency of occurrence?

Unfortunately I'm struggling to describe my problem mathematically. I have 2000 strings, many of which are repeated. Now I want to write a 'random' sampling algorithm that produces 100 samples out of ...
1 vote
34 views

### Variance of the sum of multiple random number generators

Let's assume I have "n" random number generators, each one has a different variance value, but has the same mean value, zero. If I generate "n" random numbers with these generators,...
1k views

### Algorithm for sampling fixed number of samples from a finite population

I'm looking for an algorithm that would do the following: Imagine that you need to sample uniformly at random and without replacement $k$ elements from a pool of $n$ elements. The catch is that $n$ is ...
• 113k
1 vote
43 views

### How to generate a random integer in R [closed]

I am trying to generate a random integer that follows this distribution. $$P(X=k)=p(1-p)^{k-1}$$ for $$k=1,2,...$$ I tried to use sample with some numbers, but i do not know how to use the ...
11 views

### Can an inhomogeneous Poisson process $N(t)$ be obtained from a profile of the total instantaneous population size?

Suppose I have the total instantaneous population size as function of time $t$, $n(t)$. I want to obtain the sample arrival process $N(t)$ (a counting process, which is non-decreasing), assuming that ...
• 101
1 vote
39 views

### How to generate a random sample to follow a given distribution, once weighted? [closed]

Most statistics packages allow for generating samples from a prescribed distribution; usually, by applying the inverse CDF on a sample generated uniformly on [0,1]. Now, imagine that I would like to ...
• 183
32 views

### Random numbers with exponentiated gamma distribution? [closed]

How to get random numbers following "exponentiated gamma distribution"? I tried to search some functions in R and this is what i got: https://rdrr.io/cran/Newdistns/man/expg.html I want to ...
• 77
25 views

### Generate mock data following specific conditions

I would like to generate mock stock prices satisfying a certain condition. I define the stock price as a function of time $S(t)$. I can resample the price in a given timeframe such that I can have ...
• 213
1 vote
46 views

### Can one perform Bernoulli trial by restarting trial if everyone is assigned control or treatment?

Suppose I have $n$ patient. I want to give an assignment of treatment such that probability of patients receiving treatment is $0.5$. Say I have $n$ unbiased coins to determine treatment or control ...
• 839
333 views

### How can I reduce the number of times people are randomly assigned to the same team when using a random number generator?

I am randomly assigning people to play on different golf teams each week. I have 7 teams, each with 4 players. My starting list is ordered alphabetically by last name. I’m using a random number ...
• 183
1 vote
164 views

### Sampling from multivariate truncated normal?

I try to implement this procedure. Edit: I report the mathematical steps here: Let $Y \sim TN_d(0,\Sigma, -l, +\infty)$ if $Y = Z | Z \ge -l$ with $Z \sim N_d(0, \Sigma)$ i.e. a multivariate normal ...
16 views

### Estimating the sample size of pilot study by using variance covariance as an estimator for structural equation modeling

I am not from an advanced statistical background, therefore feel free to correct and teach me if you found any mistakes that I have made below. Recently, I am interested and learning a Monte Carlo ...
38 views

### Python: Generating conditionally dependent probabilities for Apriori data generation

Goal: I want to generate fake transaction data to use as input to the Apriori association rule mining algorithm using python (3.9). The data should be generated such that for some reasonable* ...
48 views

### Understanding a Gaussian Sampler

I recently learned that you can generate a Gaussian sampler from a uniform sampler. One such method is the Box-Muller Transform. I naïvely implemented this transform in the following code: ...
• 165
77 views

### How to generate a random number with normal distribution given confidence intervals?

I have broken down a project in to some list of tasks. For each task, I've worked with some experts to come up with 90% confidence intervals. e.g. I'm 90% sure task A will be more than L hours and 90% ...
• 115
1 vote
22 views

### How to random generate a sample from {0,2} in R? [closed]

There are some solutions online on how to do a random generation of the discrete uniform distribution, but only on consecutive integers. Like : ...
1 vote
32 views

### Generated random samples of dependent ratios

The question is simple, however I am stuck: I am trying to generate samples of ratios of "detections" vs "non-detections": Say I counted 10 stars, and I could detect 8 stars. My ...
95 views

### loss function that penalizes empirical CDF

I have been doing literature review of generative models. From what I gather, there are likelihood based generative models that model the likelihood and use it as objective function to learn the ...
• 165
71 views

### Why I get high observation when I generate data from t-distribution in R

I want to generate 200 samples from t-distribution with the degree of freedom=1 and sample size is 10 and in R I use this code ...
1 vote
21 views

### Method to compare two pseudorandom number generators (PRNGs) using NIST?

I have to create two pseudorandom number generators and test which one produces a more random output using NIST. Could someone suggest a setup whereby I can confirm or deny that one pseudorandom ...
22 views

### How to simulate two datasets that satisfy specific constraints such as having specific mean , standard deviation, and correlation coefficient? [duplicate]

I know that generating different random datasets having certain standard deviation and mean values are possible. However, I'm just wondering if it's also possible to generate, let's say 2 datasets, ...
1 vote
45 views

### How to calculate Lévy random number

The calculation process of the Lévy distribution is: $$\mathrm{L\acute{e}vy}(\beta) \sim \frac{\varphi \times u}{|v|^\frac{1}{\beta}}$$ where $\mathrm{L\acute{e}vy}(\beta)$ is a Lévy random number ...
31 views

### The inverse cumulative distribution function evaluated at Halton draws [duplicate]

Sandor and Train (2004, Quasi-random simulation of discrete choice models) mention that "A randomized Halton sequence is a set of draws from the uniform distribution. To obtain draws from density ...
• 473
405 views

### How to determine the likelihood a random number generator is using a uniform distribution?

Let's say I have a blackbox function generate_number() that generates a random number between 1-N; and assume N is known. Each ...
• 193
1 vote
108 views

### True mean of a truncated distribution?

I use C++ GSL library to generate random numbers now. The numbers obey a distribution, (e.g. normal or lognormal distribution). This library requires the input of expected value ${\mu}$ (i.e. mean) ...
78 views

### Approximating joint distribution from marginals and additional information

Consider a population generation question where we are trying to generate couples that conform to a local areas demographics. We know the age distribution for Partner 1, $x_1\sim D_1$, and for ...
• 116
72 views

### Generate a multivariate normal vector

I'm working in R and I was wondering, let's say I want to generate a random vector $X \in \mathbb{R^p}$, with $X \sim N(0,I)$ where $I$ is the identity matriz in $\mathbb{R}^{p \times p}$. The ...
• 157
43 views

### Initial value of the error variance to generate random variable [closed]

We have, $y_{ij}=x_i(t_{ij})+e_{ij}$ where $y_i|u_i \sim N(x_i(t_i),\sigma_e^2I_{m_i})$ and $f(y_i)=\int_u f(y_i|u)f(u)du$ and $u_i\sim N(0,1)$. and $e_{ij} \sim N(0,\sigma_e^2)$. I am gonna use an ...
• 19
169 views

### Monte Carlo simulation for generating random numbers from a distribution [closed]

Describe Monte Carlo simulation technique and mention its different steps. Also describe how would you generate random numbers from Weibull distribution with parameters (θ, β) . In this question, I ...
• 437
1 vote
82 views

### Generating random variable from no closed-form marginal density [closed]

Suppose $u\sim N(0,I_p)$ and $Y|U\sim N(x(t),\sigma_e^2I_m)$, and the marginal distribution of $y$ is $f(y)=\int_u f(y|u)f(u)du$. $x(t)$ is composite function of $u$, basically $x(t)$ is a function of ...
• 19
63 views

### Generate batches of random numbers that each are zero-sum and for which mean of the absolute values is uniformly distributed over specified interval

In the context of polls of voting results, I want to generate random numbers with specific properties to sample the possibilities within the margin of error of the poll. For example, suppose I have ...
1 vote
50 views

### Testing which of two distributions deviates more from the uniform distribution [closed]

I'm running an experiment, and am unsure what statistic I should be using for my key test. The design: People are instructed to privately use a random number generator to generate a random number (1-6,...
87 views

### Probability of facing a specific number when having N random numbers from a "discrete uniform distribution of N numbers"

What I know: with R as a random variable from a discrete uniform distribution of 1000 numbers [1, 1000]. there is a 1/1000 chance to have R=123 (or any other number in [1, 1000]) What I think I know: ...
1 vote
84 views

### Which Dieharder tests would be most useful? [closed]

The wonderful Dieharder suite has lots of different tests available: ...
• 467
305 views

### How do you know something isn't random?

Suppose I made a random number generator that's supposed to return a number 1-10, but I made it always return 4, and didn't tell you. How would you know with 100% certainty it wasn't random? Even if ...
421 views

1 vote
31 views

### How to test if the influence of changing a parameter is larger than the influence of random noise?

I have an algorithm under test that generates a vector of results, influenced by an underlying RNG. I want to test whether, when I change parameter a, the results change 'more' then when changing the ...
116 views

### R - generate deviate using probability based on known occurrence of event

In R, I want to simulate an event using a probability $p$ based on a known occurrence $k$ of the event. If I have a population of $n = 100$ individuals in a given area, and I know over a period of ...
• 71
87 views

### Can one uniformly generate complex numbers of absolute value less than a given constant $R \neq 1$? [duplicate]

Can one uniformly generate complex numbers of absolute value less than a given constant R? This would appear to be equivalent to picking points $(x,y)$ uniformly in a disk of radius R, where $x$ is ...
2k views

### How does numpy generate samples from a beta distribution?

numpy lets you generate random samples from a beta distribution (or any other arbitrary distribution) with this API: ...
• 143
I should generate data in the form $Z=Z(x,y)$ or $Z=Z(x)$ where $x,y$ are spatial variable, so that the spatial covariance results to be equal to an assigned function of the distance $h$ between two ...