ผลต่างระหว่างรุ่นของ "Week10 practice 1"
ไปยังการนำทาง
ไปยังการค้นหา
Jittat (คุย | มีส่วนร่วม) |
Jittat (คุย | มีส่วนร่วม) |
||
แถว 3: | แถว 3: | ||
Most programming languages provide library functions for generating uniform continuous random variable in the range (0,1). However, they often do not provide any functions for generating more complicated types of random variables. | Most programming languages provide library functions for generating uniform continuous random variable in the range (0,1). However, they often do not provide any functions for generating more complicated types of random variables. | ||
− | Given a uniform random variable in (0,1), we can generate Poisson and exponential random variables based on their cumulative distribution function. Here is a simple idea. Let's consider, as an example, generating a Poisson random variable with parameter <math>\lambda = 5</math>. | + | Given a uniform random variable in (0,1), we can generate Poisson and exponential random variables based on their cumulative distribution function. Here is a simple idea. Let's consider, as an example, generating a Poisson random variable with parameter <math>\lambda = 5</math>. Using the definition of [http://en.wikipedia.org/wiki/Poisson_distribution Poisson random variables], we have its pmf <math>f(i) = P\{ X = i \}</math> as in the following list (for the first few values): |
+ | |||
+ | * f(0) = 0.006738 | ||
+ | * f(1) = 0.033690 | ||
+ | * f(2) = 0.084224 | ||
+ | * f(3) = 0.140374 | ||
+ | * f(4) = 0.175467 | ||
+ | * f(5) = 0.175467 | ||
+ | * f(6) = 0.146223 | ||
+ | * f(7) = 0.104445 | ||
+ | * f(8) = 0.065278 | ||
+ | * f(9) = 0.036266 | ||
+ | |||
+ | With this we can compute cdf <math>F(i) = P\{ X\leq i} = f(0) + f(1) + \cdots + f(i)</math>: | ||
== Simulations == | == Simulations == | ||
== Relationships == | == Relationships == |
รุ่นแก้ไขเมื่อ 01:45, 28 ตุลาคม 2557
Generating Poisson and exponential random variables
Most programming languages provide library functions for generating uniform continuous random variable in the range (0,1). However, they often do not provide any functions for generating more complicated types of random variables.
Given a uniform random variable in (0,1), we can generate Poisson and exponential random variables based on their cumulative distribution function. Here is a simple idea. Let's consider, as an example, generating a Poisson random variable with parameter . Using the definition of Poisson random variables, we have its pmf as in the following list (for the first few values):
- f(0) = 0.006738
- f(1) = 0.033690
- f(2) = 0.084224
- f(3) = 0.140374
- f(4) = 0.175467
- f(5) = 0.175467
- f(6) = 0.146223
- f(7) = 0.104445
- f(8) = 0.065278
- f(9) = 0.036266
With this we can compute cdf :