I don't understand the concept of generating random variables with constraints from Monte Carlo Methods. Can some one explain in simple language the concept behind it ?
2026-03-29 04:42:49.1774759369
Algorithm to generate random numbers with constraints ?
2.4k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
1
There are 1 best solutions below
Related Questions in RANDOM-VARIABLES
- Prove that central limit theorem Is applicable to a new sequence
- Random variables in integrals, how to analyze?
- Convergence in distribution of a discretized random variable and generated sigma-algebras
- Determine the repartition of $Y$
- What is the name of concepts that are used to compare two values?
- Convergence of sequences of RV
- $\lim_{n \rightarrow \infty} P(S_n \leq \frac{3n}{2}+\sqrt3n)$
- PDF of the sum of two random variables integrates to >1
- Another definition for the support of a random variable
- Uniform distribution on the [0,2]
Related Questions in CONSTRAINTS
- Optimization - If the sum of objective functions are similar, will sum of argmax's be similar
- Find all local maxima and minima of $x^2+y^2$ subject to the constraint $x^2+2y=6$. Does $x^2+y^2$ have a global max/min on the same constraint?
- Constrained eigenvalue problem
- Constrained optimization where the choice is a function over an interval
- MILP constraints with truth table
- Convexify this optimization problem with one nonlinear (bilinear) constraint
- Second-order cone constraints
- Matching position and rotation of moving target.
- Existence of global minimum $f(x,y,z) = x + y + z$ under the constraint $x^2+xy+2y^2-z=1$
- Constrained Optimization: Lagrange Multipliers
Trending Questions
- Induction on the number of equations
- How to convince a math teacher of this simple and obvious fact?
- Find $E[XY|Y+Z=1 ]$
- Refuting the Anti-Cantor Cranks
- What are imaginary numbers?
- Determine the adjoint of $\tilde Q(x)$ for $\tilde Q(x)u:=(Qu)(x)$ where $Q:U→L^2(Ω,ℝ^d$ is a Hilbert-Schmidt operator and $U$ is a Hilbert space
- Why does this innovative method of subtraction from a third grader always work?
- How do we know that the number $1$ is not equal to the number $-1$?
- What are the Implications of having VΩ as a model for a theory?
- Defining a Galois Field based on primitive element versus polynomial?
- Can't find the relationship between two columns of numbers. Please Help
- Is computer science a branch of mathematics?
- Is there a bijection of $\mathbb{R}^n$ with itself such that the forward map is connected but the inverse is not?
- Identification of a quadrilateral as a trapezoid, rectangle, or square
- Generator of inertia group in function field extension
Popular # Hahtags
second-order-logic
numerical-methods
puzzle
logic
probability
number-theory
winding-number
real-analysis
integration
calculus
complex-analysis
sequences-and-series
proof-writing
set-theory
functions
homotopy-theory
elementary-number-theory
ordinary-differential-equations
circles
derivatives
game-theory
definite-integrals
elementary-set-theory
limits
multivariable-calculus
geometry
algebraic-number-theory
proof-verification
partial-derivative
algebra-precalculus
Popular Questions
- What is the integral of 1/x?
- How many squares actually ARE in this picture? Is this a trick question with no right answer?
- Is a matrix multiplied with its transpose something special?
- What is the difference between independent and mutually exclusive events?
- Visually stunning math concepts which are easy to explain
- taylor series of $\ln(1+x)$?
- How to tell if a set of vectors spans a space?
- Calculus question taking derivative to find horizontal tangent line
- How to determine if a function is one-to-one?
- Determine if vectors are linearly independent
- What does it mean to have a determinant equal to zero?
- Is this Batman equation for real?
- How to find perpendicular vector to another vector?
- How to find mean and median from histogram
- How many sides does a circle have?
The generation of random numbers is a very interesting part of computer science. After all, a program is deterministic, and it seems that generating random numbers is outside of a computer's reach.
There are a few simple ways to generate random numbers. A famous example is the middle-square method.
Choose a number $x_0$ (often from the current system time). Then define the sequence $x_n$ such that $x_i$ is the concatenated middle digits of the square of $x_{i-1}$.
As an example for this method, choose $x_0=53033$. This number is called the seed. With our example, we can calculate the next values of the sequence:
$$x_0=53033$$ $$x_0^2=281\textbf{24990}89$$ $$x_1=24990$$ $$x_1^2=62\textbf{45001}00$$ $$x_2=45001$$ $$\cdots$$
Seems pretty random to me. However, notice that this sequence is deterministic. If you were given the starting value, you could always find all the subsequent values. Plus, eventually we will get a value that we've seen before, and the sequence will wrap around. A quick Python program shows that this will take $20$ steps:
Since this is "somewhat" random but not truly random, programmers call such a generator pseudo-random.
Although these "pseudo-random" numbers may seem a little disingenuous, don't fret! Given large enough seeds they are quite random, sufficently so for most Monte-Carlo type analysis. Plus, if you have a determined "seed", you can recreate the same Monte-Carlo distribution by simply choosing the same seed. If you want to learn more about common pseudorandom number generators, one is the Mersenne Twister.
You also asked how generating the variables with constraints is done. A program such as the middle-square method, as shown, produces "random" values in the range $0<x_n<99999$.
Suppose, instead, we want a continuous variable $0<k_n<1$ for our Monte-Carlo distribution. Well, we could simply divide $x_n$ by $100000$ and have a pretty good approximation! Thus, when we are generating random variables with constraints, we typically use such methods to reduce a certain random number generator into our desired constraints.
Many programming languages already have built-in functions for this. For example, Python's random module has the functions "seed", which initializes the sequence to a specific value, "randrange", which finds a random integer in a range, and "random", which gives a random floating-point number in the range $[0,1)$, among many others.