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

767 questions
Filter by
Sorted by
Tagged with
59 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 ...
219 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: ...
33 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 ...
42 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 ...
30 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 ...
1 vote
45 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
22 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 ...
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 ...
1 vote
89 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
49 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 ...
26 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 ...
51 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 ...
2k views

597 views

### Why doesn't R use Inverse Transform Sampling to sample from the Exponential Distribution?

I was reading this question about the algorithm that R uses to sample from the Exponential($\lambda$) distribution. It looks like R uses the Ahrens-Dieter algorithm to sample from the exponential ...
1 vote
64 views

### Using KDE to approximate a Price vs Quantity curve

I am trying to approximate Price-vs-Quantity (P-Q) curve of a dynamic product (think Hotels, Airlines etc). As you can imagine, if you take a hotel property, the price of rooms (assuming the same room ...
56 views

### How to simulate artifical data for multinomial regression? [duplicate]

I want to use some predictors (for example, $x_1$ and $x_2$ below) to simulate the multinomial outcome (for example, with 3 levels). Below are the codes I found in another question regarding ...
227 views

### Creating a random sparse precision matrix?

In my current project, I want to create a random sparse precision matrix $\boldsymbol{P}=\boldsymbol{\Sigma}^{-1}$ (the inverse of a covariance matrix $\boldsymbol{\Sigma}$). My current procedure ...
1 vote
52 views

### how to sample two random variables from different distributions and requiring one is always larger than the other

I know one way is to sample A and B independently and then reject the samples where A<B. But I wonder if there is an easier method?
117 views

48 views

### Generating sample data from a specified model

I am reading a book on longitudinal correlated data analysis available in https://www.taylorfrancis.com/books/mono/10.1201/9781420035285/generalized-estimating-equations-james-hardin-joseph-hilbe In ...
35 views

### How much randomness is required for Gibbs sampling?

I am attempting to parallelize a program that executes hundreds of calls to Mallet's getSampledDistribution method, which is essentially an execution of Gibbs sampling over a topic distribution which ...
1 vote
580 views

### Python/numpy - conditional sampling of variables, distribution of subsequent value is based on result of previous value

I am trying to generate a random sample of multiple variables which are loosely related to each other. Meaning that "allowed" values of some variables depend on the value which is set for ...
571 views

### How can I generate random observations from a concrete copula?

Let us assume that we have two continuous random variables $X$, $Y$, with known distributions (not necessarily normal), connected/related via a concrete copula. What is a procedure to generate random ...
191 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 ...
109 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 (...