编程辅导 More on distributions CompSci 369, 2022

More on distributions CompSci 369, 2022

School of Computer Science, University of Auckland

Copyright By PowCoder代写 加微信 powcoder

Last lecture
Revisiting Basics of probability and Random variables Common distributions
Bernoulli Geometric Binomial

This lecture
reviewing expectation and variance More common distributions
Uniform (discrete and continuous) Exponential

Expectation and variance

Expectation (or mean)
The expectation gives us an idea of the central value of the variable. The expected value of a random variable is
It is commonly called the average or mean
For discrete random variables, the integrals replaced by a sum
The symbol is often used for the mean.
.xpx ∑ = ]X[E

Example: mean of an Exponentially distributed random variable
An exponentially distributed variable .
with parameter has density function (some work) .
E.g., when
, the mean is
5.0 = λ/1 2 = λ
1−λ = = xdxλ−eλx ∞−∫ = xd)x(fx ∞−∫ = ]X[E ∞∞
xλ−eλ = )x(f

Example: PDF of a Beta distributed random variable showing the mean

5.3 = 6/12 = 6/1x 1=x∑ = )x(Xpx X∈x∑ = ]X[E 6

Variance measures the spread of a random variable about its mean. Dened by
Variance is the expected value of the square of the distance of the random variable from its mean.
2)]X[E( − ]2X[E = ]2)]X[E − X([E = )X(raV
0 ≥ )X(raV

Example: When uniform over
Saw above that . So
is discrete and
7619.2 = 25.3 − 7661.51 = 2)]X[E( − ]2X[E = )X(ra V
7661.51 = 6/19 = 6/12x 1=x∑ = ]2 X[E 6
6/1 = )x(Xp X
5.3 = ]X[E

Functions of a random varaible
A function of a random variable is simply a function that takes as it input a random variable.
Let be a function of the random variable .
Then is a random variable and can be treated as such.
For example: the expectation of is .
xd)x(Xp)x(g ∞−∫ = ]G[E )X(g ∞

Discrete distributions

Binomial PDF
.n , … ,2 ,1 ,0 = x rof x−n)p − 1(xp)x( = )x = X(P = )x(f n
.!)x−n(!x =)x( !n n

Binomial mean and variance
Expectation of is
The variance of is
has a binomial distribution with parameters and
p n X )p ,n(niB ∼ X
qpn = )p−1(pn = ]X[raV X pn = ]X[E X

Binomial Example
Let . If , 30 random draws from a binomial (n = 30, p = 0.5) distribution look like
While when , 30 random draws from Bin(n = 30, p = 0.2) look like
324341543674453834665675439735]1[ ##
219 111111]62[## 015121018 7 8 315 418 7 8 119 21118 016 2151014101]1[ ##
)2.0 = borp,02 = ezis ,03(monibr 2.0 = p
)5.0 = borp,02 = ezis ,03(monibr 5.0=p 02=n

Poisson distribution
Named after the French mathematician Siméon .
Used to model the number of rare events that occur in a xed period of time. Events occur independently of each other: one event occur does not precipitate or hinder another event occurring.
Single parameter, , called the rate parameter (higher rate produces more events).
Poisson is a count so possible values are
…,3,2,1,0

Poisson PDF
where by denition.
…,3,2,1,0 = x rof !x )λ−(pxe = )x(f xλ

Poission expectation and variance
If is Poisson it has expectation
and variance
Write when has a Poisson distribution with parameter .
λ X )λ(ssioP ∼ X .λ = ]X[raV

Poisson example
30 random draws from a Poisson distribution with rate look like
While when , 30 random draws look like
020001013012120100110100201000]1[ ##
122303230124513421124011332111]1[ ##
)5.0 = adbmal,03(siopr 5.0 = λ
)2 = adbmal,03(siopr

Can apply to discrete or continuous values All allowable outcomes are equally likely.

Discrete uniform
When is discrete and takes possible values, the uniform pdf is for all .
ix n/1 = )ix = X(P nX

Continuous uniform
When uniform over on , the density function is . Write .
a−b =)x(f ]b,a[ X 1
)]b,a[(U ∼ X

Uniform Examples
30 random draws from a discrete uniform distribution with possible outcomes 1,2,..,8:
30 random draws from (rounded to 3 dp)
969.4 512.2 555.4 918.5 937.5 416.4 ]52[ ##
702.3 355.3 225.4 444.5 956.2 945.3 925.4 562.2 435.2 890.5 409.4 037.5 ]31[ ##
355.5 320.2 813.2 682.2 381.3 031.5 398.4 897.3 745.4 020.4 812.2 506.3 ]1[ ##
)3 = stigid ,)6 = xam ,2 = nim ,03(finur(dnuor )]6 ,2[( U
475138548634518331517255341472]1[ ##
)T = ecalper,03 = ezis,8:1(elpmas

Continuous distributions

Exponential
The exponential distribution describes the waiting time between independent events.
Takes any non-negative value:
It has a single parameter, , known as the rate.

Exponential density
The probability density function for exponential is , where .
xλ−eλ = )x(f X
)λ(pxE ∼ X 0≥x

Exponential mean and variance
The expectation of is .
The variance of is
2λ =)X(raV X 1
λ=]X[E X 1

Exponential example
30 random draws from an exponential distribution with rate parameter .
When , 30 draws look like
341.0 045.1 426.2 661.0 270.2 385.0 ]52[ ##
889.1 713.0 974.1 984.1 248.2 211.0 028.0 539.1 339.2 639.3 012.2 493.1 ]31[ ##
754.0 857.0 304.0 927.0 429.0 815.1 165.1 401.5 732.0 349.3 612.0 360.2 ]1[ ##
234.1 272.0 340.0 212.0 744.0 180.0 ]52[ ##
413.0 701.0 773.0 314.0 233.0 693.0 140.0 582.1 892.0 400.0 279.0 522.0 ]31[ ##
137.1 536.0 270.0 653.0 702.0 500.1 803.0 014.0 281.0 420.3 858.0 082.0 ]1[ ##
)3 = stigid,)5.0 = etar,03(pxer(dnuor 5.0 = λ
)3 = stigid ,)2 = etar,03(pxer(dnuor

Memorylessness
An important property of the exponential distribution is memorylessness. Memorylessness is a property is shared with the geometric distribution and no
other distributions.
So if you insist on the memoryless property, you are insisting on a geometric or exponential distribution.
Formally, if is exponentially distributed, it has the memoryless property that
.0≥y,x∀ ,)x>X(rP=)y> T|x+y>X(rP X

Gamma distribution
The Gamma distribution arises as the sum of a number of exponentials. Two parameters: and called the shape and scale, respectively.
These parameters can be used to specify the mean and variance of the distribution.
.)θ ,k(ammaG ∼ X

where is the gamma function (the extension of the factorial function, , to all real numbers).
,0 > x rof )θ/x−(pxe 1−kx )k(Γkθ = )x(f 1
td t−e1−kt 0∫ = )k(Γ ∞

Gamma mean and variance
The mean a gamma distributed random variable is The variance of is .
Gamma distribution has dierent parameterisations which result in dierent looking (but mathematically equivalent) expressions for the density, mean and variance — be sure to check which parametrisation is being used.
θk = ]X[E X
2θk = )X(raV X

Normal distribution
The normal distribution arises as a consequence of the central limit theorem which says that (under a few weak assumptions) the sum of a set of identical random variables is well approximated by a normal distribution.
Thus when random eects all add together, they often result in a normal distribution. Measurement error terms are typically modeled as normally distributed.

Normal PDF
The Normal distribution, with mean and variance , ( ) has density function
We write .
} )μ−x(2σ2−{pxeπ2√σ =)x(f 211
0>σ,R∈μ 2σ μ
)2σ,μ(N ∼ X

Relationships between distributions
As we have seen, many distributions are derived by transforming one or more random variables drawn from another distribution. E.g.,
Geometric is just the number of Bernoulli’s before the rst success binomial is the sum of Bernoulli’s
Gamma is the sum of exponentials.
exponential distribution as the continuous analogue of the geometric distribution
the Normal as a continuous analogue of the binomial.
These relationships will help us later when we need to simulate from dierent distributions in that if can simulate draws from one distribution, we may be able to transform them into draws from another distribution.
There are some nice diagrams showing the complex relationships here and here.

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com