3.3 Continuous Random Variables | Simulation And Modelling To ...
Maybe your like
- Simulation and Modelling to Understand Change
- Preface
- 1 Introduction
- 1.1 What is simulation
- 1.1.1 A simple simulation model
- 1.1.2 Why simulate?
- 1.2 Types of simulations
- 1.2.1 Stochastic vs deterministic simulations
- 1.2.2 Static vs dynamic simulations
- 1.2.3 Discrete vs continuous simulations
- 1.3 Elements of a simulation model
- 1.3.1 Objects of the model
- 1.3.2 Organization of entities and resources
- 1.3.3 Operations of the objects
- 1.4 The donut shop example
- 1.5 Simulating a little health center
- 1.6 What’s next
- 1.1 What is simulation
- 2 R programming
- 2.1 Why R?
- 2.2 R basics
- 2.2.1 R as a calculator
- 2.2.2 Variable assignment
- 2.2.3 Data types
- 2.2.4 Vectors
- 2.2.5 Matrices
- 2.2.6 Dataframes
- 2.2.7 NULL and NA
- 2.3 Accessing and manipulating variables
- 2.3.1 Accessing a single element
- 2.3.2 Acessing multiple entries
- 2.3.3 Accessing entries with logical operators
- 2.3.4 Manipulating dataframes
- 2.3.5 Information about objects
- 2.4 Loops and conditions
- 2.4.1 if statements
- 2.4.2 ifelse
- 2.4.3 Loops
- 2.5 Functions
- 2.5.1 Defining your own function
- 2.5.2 Calling functions
- 2.5.3 Mathematical and statistical functions
- 2.6 The apply family of functions
- 2.6.1 The function apply
- 2.6.2 The function sapply
- 2.7 The pipe operator
- 2.8 Plotting
- 3 Probability Basics
- 3.1 Discrete Random Variables
- 3.1.1 Probability Mass Function
- 3.1.2 Cumulative Distribution Function
- 3.1.3 Summaries
- 3.2 Notable Discrete Variables
- 3.2.1 Bernoulli Distribution
- 3.2.2 Binomial Distribution
- 3.2.3 Poisson Distribution
- 3.2.4 Some Examples
- 3.3 Continuous Random Variables
- 3.3.1 Probability Density Function
- 3.3.2 Cumulative Distribution Function
- 3.3.3 Summaries
- 3.4 Notable Continuous Distribution
- 3.4.1 Uniform Distribution
- 3.4.2 Exponential Distribution
- 3.4.3 Normal Distribution
- 3.5 The Central Limit Theorem
- 3.1 Discrete Random Variables
- 4 Random Number Generation
- 4.1 Properties of Random Numbers
- 4.2 Pseudo Random Numbers
- 4.3 Generating Pseudo-Random Numbers
- 4.3.1 Generating Pseudo-Random Numbers in R
- 4.3.2 Linear Congruential Method
- 4.4 Testing Randomness
- 4.4.1 Testing Uniformity
- 4.4.2 Testing Independence
- 4.5 Random Variate Generation
- 4.5.1 Random Generation in R
- 4.5.2 The Inverse Transform Method
- 4.5.3 Simulating Bernoulli and Binomial
- 4.5.4 Simulating Other Distributions
- 4.6 Testing Generic Simulation Sequences
- 4.6.1 Testing Distribution Fit
- 4.6.2 Testing Independence
- 5 Monte Carlo Simulation
- 5.1 What does Monte Carlo simulation mean?
- 5.2 A bit of history
- 5.3 Steps of Monte Carlo simulation
- 5.3.1 Estimating \(\pi\): step 1
- 5.3.2 Estimating \(\pi\): step 2
- 5.3.3 Estimating \(\pi\): step 3
- 5.3.4 Estimating \(\pi\): step 4
- 5.3.5 Estimating \(\pi\): step 5
- 5.3.6 Estimating \(\pi\): conclusions
- 5.4 The sample function
- 5.5 A game of chance
- 5.6 Playing the roulette
- 5.6.1 Question 1
- 5.6.2 Question 2
- 5.6.3 Question 3
- 5.7 Is Annie meeting Sam?
- 5.7.1 Question 1
- 5.7.2 Question 2
- 5.7.3 Question 3
- 5.7.4 Question 4
- 6 Discrete Event Simulation
- 6.1 The donut shop
- 6.1.1 A single customer at a fixed time
- 6.1.2 A customer arriving at random
- 6.1.3 Many random customers
- 6.1.4 The donut shop with a service counter
- 6.1.5 Several service counters
- 6.1.6 Simple visualizations
- 6.2 Replication
- 6.3 The donut shop - advanced features
- 6.3.1 Priority customers without preemption
- 6.3.2 Priority customers with preemption
- 6.3.3 Balking customers
- 6.3.4 Reneging (or abandoning) customers
- 6.3.5 Several counters with individual queues
- 6.3.6 Opening times
- 6.3.7 Batching clients
- 6.4 Simulating a simple health center
- 6.5 A production process simulation
- 6.1 The donut shop
- 7 Queuing Theory
- 7.1 Poisson Process
- 7.2 Characteristics of Queuing Systems
- 7.2.1 The Calling Population
- 7.2.2 System Capacity
- 7.2.3 The Arrival Process
- 7.2.4 Queue Behavior and Queue Discipline
- 7.2.5 Service Times and Service Mechanism
- 7.3 Queuing Notation
- 7.4 Measures of Performance
- 7.4.1 Average Number of Customers in the System \(L\)
- 7.4.2 Average Time Spent in System per Customer \(w\)
- 7.4.3 Little’s Law
- 7.4.4 Server Utilization
- 7.5 Steady-State Behavior of the M/M/1 Model
- Published with bookdown
3.3 Continuous Random Variables
Our attention now turns to continuous random variables. These are in general more technical and less intuitive than discrete ones. You should not worry about all the technical details, since these are in general not important, and focus on the interpretation.
A continuous random variable \(X\) is a random variable whose sample space \(\mathbb{X}\) is an interval or a collection of intervals. In general \(\mathbb{X}\) may coincide with the set of real numbers \(\mathbb{R}\) or some subset of it. Examples of continuous random variables:
the pressure of a tire of a car: it can be any positive real number;
the current temperature in the city of Madrid: it can be any real number;
the height of the students of Simulation and Modeling to understand change: it can be any real number.
Whilst for discrete random variables we considered summations over the elements of \(\mathbb{X}\), i.e. \(\sum_{x\in\mathbb{X}}\), for continuous random variables we need to consider integrals over appropriate intervals.
You should be more or less familiar with these from previous studies of calculus. But let’s give an example. Consider the function \(f(x)=x^2\) computing the squared of a number \(x\). Suppose we are interested in this function between the values -1 and 1, which is plotted by the red line in Figure 3.6. Consider the so-called integral \(\int_{-1}^{1}x^2dx\): this coincides with the area delimited by the function and the x-axis. In Figure 3.6 the blue area is therefore equal to \(\int_{-1}^{1}x^2dx\).
Figure 3.6: Plot of the squared function and the area under its curve
We will not be interested in computing integrals ourselves, so if you do not know/remember how to do it, there is no problem!
3.3.1 Probability Density Function
Discrete random variable are easy to work with in the sense that there exists a function, that we called probability mass function, such that \(p(x)=P(X=x)\), that is the value of that function in the point \(x\) is exactly the probability that \(X=x\).
Therefore we may wonder if this is true for a continuous random variable too. Sadly, the answer is no and probabilities for continuous random variables are defined in a slightly more involved way.
Let \(X\) be a continuous random variable with sample space \(\mathbb{X}\). The probability that \(X\) takes values in the interval \([a,b]\) is given by \[ P(a\leq X \leq b) = \int_{a}^bf(x)dx \] where \(f(x)\) is called the probability density function (pdf in short). Pdfs, just like pmfs must obey two conditions:
\(f(x)\geq 0\) for all \(x\in\mathbb{X}\);
\(\int_{x\in\mathbb{X}}f(x)dx=1\).
So in the discrete case the pmf is defined exactly as the probability. In the continuous case the pdf is the function such that its integral is the probability that random variable takes values in a specific interval.
As a consequence of this definition notice that for any specific value \(x_0\in\mathbb{X}\), \(P(X=x_0)=0\) since \[ \int_{x_0}^{x_0}f(x)dx = 0. \]
Let’s consider an example. The waiting time of customers of a donuts shop is believed to be random and to follow a random variable whose pdf is \[ f(x) = \left\{ \begin{array}{ll} \frac{1}{4}e^{-x/4}, & x\geq 0\\ 0, & \mbox{otherwise} \end{array} \right. \]
The pdf is drawn in Figure 3.7 by the red line. One can see that \(f(x)\geq 0\) for all \(x\geq 0\) and one could also compute that it integrates to one.
Therefore the probability that the waiting time is between any two values \((a,b)\) can be computed as \[ \int_a^b\frac{1}{4}e^{-x/4}dx. \] In particular if we were interested in the probability that the waiting time is between two and five minutes, corresponding to the shaded area in Figure 3.7, we could compute it as \[ P(2<X<5)=\int_2^5f(x)dx=\int_{2}^5\frac{1}{4}e^{-x/4}dx= 0.32 \]
Figure 3.7: Probability density function for the waiting time in the donut shop example
Notice that since \(P(X=x_0)=0\) for any \(x_0\in\mathbb{X}\), we also have that \[ P(a\leq X \leq b)=P(a < X \leq b) = P(a\leq X < b) = P(a<X<b). \]
3.3.2 Cumulative Distribution Function
For a continuous random variable \(X\) the cumulative distribution function (cdf) is equally defined as \[ F(x) = P(X \leq x), \] where now \[ P(X \leq x) = P(X < x) = \int_{-\infty}^xf(t)dt. \] so the summation is substituted by an integral.
Let’s consider again the donut shop example as an illustration. The cdf is defined as \[ F(x)=\int_{-\infty}^xf(t)dt = \int_{-\infty}^x\frac{1}{4}e^{-x/4}. \] This integral can be solved and \(F(x)\) can be calculated as \[ F(x)= 1- e^{-x/4}, \] which is plotted in Figure 3.8.
Figure 3.8: Cumulative distribution function for the waiting time at the donut shop
We can notice that the cdf has similar properties as in the discrete case: it is non-decreasing, on the left-hand side is zero and on the right-hand side tends to zero.
In the continuous case, one can prove that cdfs and pdfs are related as \[ f(x)=\frac{d}{dx}F(x). \]
3.3.3 Summaries
Just as for discrete random variables, we may want to summarize some features of a continuous random variable into a unique number. The same set of summaries exists for continuous random variables, which are almost exactly defined as in the discrete case (integrals are used instead of summations).
mean: the mean of a continuous random variable \(X\) is defined as \[ E(X) = \int_{-\infty}^{+\infty}xf(x)dx \]
median: the median of a continuous random variable \(X\) is defined as the value \(x\) such that \(P(X\leq x) = 0.5\) or equally \(F(x)=0.5\).
mode: the mode of a continuous random variable \(X\) is defined the value \(x\) such that \(f(x)\) is largest.
variance: the variance of a continuous random variable \(X\) is defined as \[ V(X)=\int_{-\infty}^{+\infty}(x-E(X))^2f(x)dx \]
standard deviation: the standard deviation of a continuous random variable \(X\) is defined as \(\sqrt{V(X)}\).
Tag » What Are Continuous Random Variables
-
7.1: What Is A Continuous Random Variable? - Statistics LibreTexts
-
Continuous Random Variable - Definition, Formulas, Mean, Examples
-
Continuous Random Variables – Maths A-Level Revision
-
Continuous Random Variables - Definition | Brilliant Math & Science ...
-
Discrete Random Variables
-
[PDF] Continuous Random Variables And Probability Distributions
-
Continuous Random Variable | Definition, Examples, Explanation
-
Discrete And Continuous Random Variables - Henry County Schools
-
[PDF] Continuous Random Variables - Illinois Math
-
The Probability Distribution Of A Continuous Random Variable
-
Continuous Random Variables | Aprende Con Alf
-
Random Variable - Wikipedia
-
What Are Continuous Random Variables? (1 Of 3 - YouTube
-
Lesson Explainer: Continuous Random Variables - Nagwa