Last modified: August 21, 2023
This article is written in: πΊπΈ
Uniform Distribution
A continuous random variable X follows a uniform distribution over an interval [a, b] if it has a constant probability density over that interval. The uniform distribution is denoted as XβΌUniform(a,b).
Probability Density Function (PDF)
The PDF of a uniform distribution is given by:
f(x)={1bβa,if aβ€xβ€b0,otherwise
Cumulative Distribution Function (CDF)
The CDF of a uniform distribution is given by:
F(x)={0,if x<axβabβa,if aβ€xβ€b1,if x>b
Expected Value and Variance
The expected value (mean) of a uniform distribution is the midpoint of the interval [a, b]:
E[X]=a+b2
The variance of a uniform distribution is given by:
Var(X)=(bβa)212
Moment Generating Functions and Moments
The moment generating function (MGF) of a uniform distribution is:
MX(t)=E[etX]=etbβetat(bβa)
To find the n-th moment, we take the n-th derivative of the MGF with respect to t and then evaluate it at t=0:
E[Xn]=dnMX(t)dtn|t=0
- First Moment (Mean):
E[X]=a+b2
- Second Moment (Variance + Mean^2):
E[X2]=a2+ab+b23
Example: Timing in Simulation Game
In a simulation game, a developer wants to introduce an event occurring randomly between 2 and 4 seconds after a certain action. This timing follows a continuous uniform distribution.
Given parameters:
- Lower bound a=2 seconds
- Upper bound b=4 seconds
I. Probability of Event Occurring Within 2.5 Seconds:
For a continuous uniform distribution U(a,b), the probability density function is f(x;a,b)=1bβa for aβ€xβ€b.
To find the probability of the event happening before 2.5 seconds:
P(X<2.5)=2.5β24β2=0.25
This means there is a 25% chance the event will occur within 2.5 seconds.
II. Expected Value and Variance of the Event Timing:
The expected value E[X] and variance Var(X) for a continuous uniform distribution are calculated as:
- Expected value (mean time):
E[X]=a+b2=2+42=3 seconds
- Variance:
Var(X)=(bβa)212=(4β2)212=13 seconds2
These calculations help the developer understand the timing dynamics of the event in the simulation game.
Applications
Uniform distributions are often used as a simple model when all possible outcomes are equally likely, such as in random number generators or when sampling from a finite set of values.