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
0 votes
0 answers
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 ...
user avatar
  • 61
0 votes
0 answers
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 ...
user avatar
0 votes
0 answers
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 (...
user avatar
  • 184
0 votes
0 answers
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 ...
user avatar
  • 1
1 vote
2 answers
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,...
user avatar
20 votes
3 answers
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 ...
user avatar
  • 113k
1 vote
1 answer
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 ...
user avatar
0 votes
0 answers
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 ...
user avatar
1 vote
0 answers
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 ...
user avatar
  • 183
0 votes
1 answer
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 ...
user avatar
  • 77
0 votes
0 answers
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 ...
user avatar
  • 213
1 vote
2 answers
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 ...
user avatar
  • 839
8 votes
1 answer
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 ...
user avatar
  • 183
1 vote
0 answers
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 ...
user avatar
0 votes
0 answers
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 ...
user avatar
0 votes
0 answers
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* ...
user avatar
4 votes
1 answer
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: ...
user avatar
  • 165
0 votes
1 answer
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% ...
user avatar
  • 115
1 vote
1 answer
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 : ...
user avatar
1 vote
1 answer
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 ...
user avatar
3 votes
1 answer
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 ...
user avatar
2 votes
2 answers
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 ...
user avatar
1 vote
0 answers
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 ...
user avatar
0 votes
0 answers
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, ...
user avatar
1 vote
0 answers
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 ...
user avatar
0 votes
0 answers
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 ...
user avatar
  • 473
9 votes
2 answers
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 ...
user avatar
  • 193
1 vote
2 answers
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) ...
user avatar
2 votes
0 answers
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 ...
user avatar
  • 116
0 votes
1 answer
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 ...
user avatar
  • 157
-1 votes
1 answer
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 ...
user avatar
  • 19
0 votes
2 answers
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 ...
user avatar
  • 437
1 vote
1 answer
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 ...
user avatar
  • 19
0 votes
0 answers
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 ...
user avatar
1 vote
2 answers
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,...
user avatar
3 votes
1 answer
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: ...
user avatar
1 vote
0 answers
84 views

Which Dieharder tests would be most useful? [closed]

The wonderful Dieharder suite has lots of different tests available: ...
user avatar
10 votes
5 answers
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 ...
user avatar
17 votes
3 answers
421 views

Sampling from $x^2\phi(x)$?

Given that $\int_{-\infty}^{\infty}x^2\phi(x)dx < \infty$, where $\phi(x)$ is the standard normal probability density function, we can define the new pdf $$f(x) = \frac{x^2\phi(x)}{\int_{-\infty}^{\...
user avatar
  • 173
1 vote
2 answers
84 views

How to set up the matrix in data generation in R?

I am trying to generate two continuous predictors and one continuous outcome from mvrnorm. Now, I am trying to set up both standardized slopes at 0.3. This is my R ...
user avatar
  • 21
-2 votes
2 answers
93 views

Box-Muller: Generate i.i.d Standard Normal from 1 Chi-squared and 1 Unit Uniform RV [closed]

Situation: I am given one chi-square RV and one unit uniform random RV. Question: How can I use the Box-Muller method to generate i.i.d. standard normal random samples using only these two RVs, ...
user avatar
1 vote
2 answers
236 views

Random number generator seed in R

I have a question about the random number generator seed number in R. Recently, I am trying to solve the exercises in the book named "An Introduction to Statistical Learning". When I ...
user avatar
  • 501
3 votes
2 answers
697 views

Generation of random variables via composition and inversion

What are the main pros and cons of each method and when to use each one? Law [2007] mentions that: "Again, the reader is encouraged to develop the inverse-transform method for generating a ...
user avatar
4 votes
1 answer
781 views

What is the best way to sample points from an arbitrary 2D distribution?

I want to sample points $(x,y)$ randomly according to the Himmelblau function $$f(x,y) = (x^2 + y - 11)^2 + (x + y^2 - 7)^2\qquad -5\le x,y\le 5$$ which I treat as a multivariate probability density ...
user avatar
1 vote
0 answers
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 ...
user avatar
2 votes
1 answer
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 ...
user avatar
  • 71
0 votes
1 answer
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 ...
user avatar
2 votes
1 answer
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: ...
user avatar
  • 143
0 votes
0 answers
109 views

Generating spatially correlated data with assigned spatial covariance

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 ...
user avatar
1 vote
0 answers
78 views

Generate uniform distribution under multiple constraints

I have to acknowledge that my skill in statistics are really rusted. I would like to implement in Python a uniform distribution that satisfies constraints on the mean, the median, the standard ...
user avatar

1
2 3 4 5
15