Random Variables and Distribution Functions

Similar documents
Orbits and Kepler s Laws

Summary: Vectors. This theorem is used to find any points (or position vectors) on a given line (direction vector). Two ways RT can be applied:

(1) continuity equation: 0. momentum equation: u v g (2) u x. 1 a

9 CONTINUOUS DISTRIBUTIONS

r (1+cos(θ)) sin(θ) C θ 2 r cos θ 2

Intro to Circle Geometry By Raymond Cheong

Polynomial Functions. Polynomial functions in one variable can be written in expanded form as ( )

N V V L. R a L I. Transformer Equation Notes

Screentrade Car Insurance Policy Summary

Curvature. (Com S 477/577 Notes) Yan-Bin Jia. Oct 8, 2015

Example 27.1 Draw a Venn diagram to show the relationship between counting numbers, whole numbers, integers, and rational numbers.

Lecture 3 Gaussian Probability Distribution

Bayesian Updating with Continuous Priors Class 13, 18.05, Spring 2014 Jeremy Orloff and Jonathan Bloom

Helicopter Theme and Variations

(Ch. 22.5) 2. What is the magnitude (in pc) of a point charge whose electric field 50 cm away has a magnitude of 2V/m?

MATH 150 HOMEWORK 4 SOLUTIONS

Example A rectangular box without lid is to be made from a square cardboard of sides 18 cm by cutting equal squares from each corner and then folding

Continuous Compounding and Annualization

SPECIAL PRODUCTS AND FACTORIZATION

Adaptive Control of a Production and Maintenance System with Unknown Deterioration and Obsolescence Rates

Algebra Review. How well do you remember your algebra?

Factoring Polynomials

PROF. BOYAN KOSTADINOV NEW YORK CITY COLLEGE OF TECHNOLOGY, CUNY

32. The Tangency Problem of Apollonius.

Mathematics. Vectors. hsn.uk.net. Higher. Contents. Vectors 128 HSN23100

Appendix D: Completing the Square and the Quadratic Formula. In Appendix A, two special cases of expanding brackets were considered:

MODULE 3. 0, y = 0 for all y

4.11 Inner Product Spaces

5.2. LINE INTEGRALS 265. Let us quickly review the kind of integrals we have studied so far before we introduce a new one.


UNIT CIRCLE TRIGONOMETRY

Math 135 Circles and Completing the Square Examples

FUNCTIONS DEFINED BY IMPROPER INTEGRALS

LINEAR TRANSFORMATIONS AND THEIR REPRESENTING MATRICES

Integration. 148 Chapter 7 Integration

Unit 6: Exponents and Radicals

Graphs on Logarithmic and Semilogarithmic Paper


Operations with Polynomials

16. Mean Square Estimation

AREA OF A SURFACE OF REVOLUTION

LAPLACE S EQUATION IN SPHERICAL COORDINATES. With Applications to Electrodynamics

Exam in physics, El-grunder (Electromagnetism), , kl

SOEPpapers on Multidisciplinary Panel Data Research

Lecture 5. Inner Product

Second Term MAT2060B 1. Supplementary Notes 3 Interchange of Differentiation and Integration

and thus, they are similar. If k = 3 then the Jordan form of both matrices is

Homework 3 Solutions


Binary Representation of Numbers Autar Kaw

EQUATIONS OF LINES AND PLANES

GRAVITATION 1. BASIC FORCES IN NATURE

Chapter 3 Savings, Present Value and Ricardian Equivalence

Vectors Recap of vectors

Figure 2. So it is very likely that the Babylonians attributed 60 units to each side of the hexagon. Its resulting perimeter would then be 360!

Section 7-4 Translation of Axes

tools for Web data extraction

INITIAL MARGIN CALCULATION ON DERIVATIVE MARKETS OPTION VALUATION FORMULAS

Physics 43 Homework Set 9 Chapter 40 Key


Exponential and Logarithmic Functions

Vector Calculus: Are you ready? Vectors in 2D and 3D Space: Review

Reasoning to Solve Equations and Inequalities

All pay auctions with certain and uncertain prizes a comment

Distributions. (corresponding to the cumulative distribution function for the discrete case).

G.GMD.1 STUDENT NOTES WS #5 1 REGULAR POLYGONS

Chapter 23 Electrical Potential

Skills Needed for Success in Calculus 1

Use Geometry Expressions to create a more complex locus of points. Find evidence for equivalence using Geometry Expressions.

Treatment Spring Late Summer Fall Mean = 1.33 Mean = 4.88 Mean = 3.

Week 3-4: Permutations and Combinations

Review guide for the final exam in Math 233

Or more simply put, when adding or subtracting quantities, their uncertainties add.

Integration by Substitution

Experiment 6: Friction

2.016 Hydrodynamics Prof. A.H. Techet

e.g. f(x) = x domain x 0 (cannot find the square root of negative values)

RIGHT TRIANGLES AND THE PYTHAGOREAN TRIPLETS

Mechanics 1: Work, Power and Kinetic Energy

Introduction to Integration Part 2: The Definite Integral

9.3. The Scalar Product. Introduction. Prerequisites. Learning Outcomes

Density Curve. Continuous Distributions. Continuous Distribution. Density Curve. Meaning of Area Under Curve. Meaning of Area Under Curve

PHY 140A: Solid State Physics. Solution to Homework #2

FUNCTIONS AND EQUATIONS. xεs. The simplest way to represent a set is by listing its members. We use the notation

Lectures 8 and 9 1 Rectangular waveguides

Econ 4721 Money and Banking Problem Set 2 Answer Key

4a 4ab b (count number of places from first non-zero digit to

Small Business Cloud Services

Lesson 7 Gauss s Law and Electric Fields

Pure C4. Revision Notes

CURVES ANDRÉ NEVES. that is, the curve α has finite length. v = p q p q. a i.e., the curve of smallest length connecting p to q is a straight line.

Mechanics 1: Motion in a Central Force Field

Scalar and Vector Quantities. A scalar is a quantity having only magnitude (and possibly phase). LECTURE 2a: VECTOR ANALYSIS Vector Algebra

Review Problems for the Final of Math 121, Fall 2014

Physics 235 Chapter 5. Chapter 5 Gravitation

19. The Fermat-Euler Prime Number Theorem

P.3 Polynomials and Factoring. P.3 an 1. Polynomial STUDY TIP. Example 1 Writing Polynomials in Standard Form. What you should learn

LECTURE #05. Learning Objective. To describe the geometry in and around a unit cell in terms of directions and planes.

est using the formula I = Prt, where I is the interest earned, P is the principal, r is the interest rate, and t is the time in years.

PHY 222 Lab 8 MOTION OF ELECTRONS IN ELECTRIC AND MAGNETIC FIELDS

Transcription:

Topic 7 Rndom Vibles nd Distibution Functions 7.1 Intoduction Fom the univese of possible infomtion, we sk question. To ddess this question, we might collect quntittive dt nd ognize it, fo emple, using the empiicl cumultive distibution function. With this infomtion, we e ble to compute smple mens, stndd devitions, medins nd so on. Similly, even fily simple pobbility model cn hve n enomous numbe of outcomes. Fo emple, flip coin 332 times. Then the numbe of outcomes is moe thn google (10 100 ) numbe t lest 100 quintillion times the numbe of elementy pticles in the known univese. We my not be inteested in n nlysis tht consides septely evey possible outcome but the some simple concept like the numbe of heds o the longest un of tils. To focus ou ttention on the issues of inteest, we tke given outcome nd compute numbe. This function is clled ndom vible. Definition 7.1. A ndom vible is el vlued function fom the pobbility spce. sttistics pobbility univese of smple spce - infomtion nd pobbility - P + + sk question nd define ndom collect dt vible X + + ognize into the ognize into the empiicl cumultive cumultive distibution function distibution function + + compute smple compute distibutionl mens nd vinces mens nd vinces Tble I: Coesponding notions between sttistics nd pobbility. Emining pobbilities models nd ndom vibles will led to sttegies fo the collection of dt nd infeence fom these dt. X :! R. Genelly speking, we shll use cpitl lettes ne the end of the lphbet, e.g., X, Y, Z fo ndom vibles. The nge S of ndom vible is sometimes clled the stte spce. Eecise 7.2. Roll die twice nd conside the smple spce ={(i, j); i, j =1, 2, 3, 4, 5, 6} nd give some ndom vibles on. Eecise 7.3. Flip coin 10 times nd conside the smple spce, the set of 10-tuples of heds nd tils, nd give some ndom vibles on. 101

We often cete new ndom vibles vi composition of functions: Thus, if X is ndom vible, then so e! 7! X(!) 7! f(x(!)) X 2, ep X, p X2 +1, tn 2 X, bxc nd so on. The lst of these, ounding down X to the neest intege, is clled the floo function. Eecise 7.4. How would we use the floo function to ound down numbe to n deciml plces. 7.2 Distibution Functions Hving defined ndom vible of inteest, X, the question typiclly becomes, Wht e the chnces tht X lnds in some subset of vlues B? Fo emple, We wite B = {odd numbes}, B = {gete thn 1}, o B = {between 2 nd 7}. {! 2 ; X(!) 2 B} (7.1) to indicte those outcomes! which hve X(!), the vlue of the ndom vible, in the subset A. We shll often bbevite (7.1) to the shote sttement {X 2 B}. Thus, fo the emple bove, we my wite the events {X is n odd numbe}, {X is gete thn 1} = {X >1}, {X is between 2 nd 7} = {2 <X<7} to coespond to the thee choices bove fo the subset B. Mny of the popeties of ndom vibles e not concened with the specific ndom vible X given bove, but the depends on the wy X distibutes its vlues. This leds to definition in the contet of ndom vibles tht we sw peviously with quntitive dt.. Definition 7.5. A (cumultive) distibution function of ndom vible X is defined by F X () =P {! 2 ; X(!) pple }. Recll tht with quntittive obsevtions, we clled the nlogous notion the empiicl cumultive distibution function. Using the bbevited nottion bove, we shll typiclly wite the less eplicit epession fo the distibution function. F X () =P {X pple } Eecise 7.6. Estblish the following identities tht elte ndom vible the complement of n event nd the union nd intesection of events 1. {X 2 B} c = {X 2 B c } 2. Fo sets B 1,B 2,..., [ {X 2 B i } = {X 2 [ i i B} nd \ {X 2 B i } = {X 2 \ i i B}. 3. If B 1,...B n fom ptition of the smple spce S, then C i = {X 2 B i }, i =1,...,nfom ptition of the pobbility spce. 102

Eecise 7.7. Fo ndom vible X nd subset B of the smple spce S, define P X (B) =P {X 2 B}. Show tht P X is pobbility. Fo the complement of {X pple }, we hve the suvivl function F X () =P {X >} =1 P {X pple } =1 F X (). Choose <b, then the event {X pple } {X pple b}. Thei set theoetic diffeence {X pple b}\{x pple } = { <Xpple b}. In wods, the event tht X is less thn o equl to b but not less thn o equl to is the event tht X is gete thn nd less thn o equl to b. Consequently, by the diffeence ule fo pobbilities, P { <Xpple b} = P ({X pple b}\{x pple }) =P {X pple b} P {X pple } = F X (b) F X (). (7.2) Thus, we cn compute the pobbility tht ndom vible tkes vlues in n intevl by subtcting the distibution function evluted t the endpoints of the intevls. Ce is needed on the issue of the inclusion o eclusion of the endpoints of the intevl. Emple 7.8. To give the cumultive distibution function fo X, the sum of the vlues fo two olls of die, we stt with the tble nd cete the gph. 2 3 4 5 6 7 8 9 10 11 12 P {X = } 1/36 2/36 3/36 4/36 5/36 6/36 5/36 4/36 3/36 2/36 1/36 1 6 3/4 1/2 1/4 1 2 3 4 5 6 7 8 9 10 11 12 - Figue 7.1: Gph of F X, the cumultive distibution function fo the sum of the vlues fo two olls of die. 103

If we look t the gph of this cumultive distibution function, we see tht it is constnt in between the possible vlues fo X nd tht the jump size t is equl to P {X = }. In this emple, P {X =5} =4/36, the size of the jump t =5. In ddition, F X (5) F X (2) = P {2 <Xpple 5} = P {X =3} + P {X =4} + P {X =5} = X P {X = } = 2 36 + 3 36 + 4 36 = 9 36. 2<pple5 We shll cll ndom vible discete if it hs finite o countbly infinite stte spce. Thus, we hve in genel tht: P { <Xpple b} = X P {X = }. <ppleb Eecise 7.9. Let X be the numbe of heds on thee independent flips of bised coin tht tuns ups heds with pobbility p. Give the cumultive distibution function F X fo X. Eecise 7.10. Let X be the numbe of spdes in collection of thee cds. Give the cumultive distibution function fo X. Use R to plot this function. Eecise 7.11. Find the cumultive distibution function of Y = X 3 in tems of F X, the distibution function fo X. 7.3 Popeties of the Distibution Function A distibution function F X hs the popety tht it stts t 0, ends t 1 nd does not decese with incesing vlues of.. This is the content of the net eecise. Eecise 7.12. 1. lim! 1 F X () =0. 2. lim!1 F X () =1. 3. F X is nondecesing. The cumultive distibution function F X of discete ndom vible X is constnt ecept fo jumps. At the jump, F X is ight continuous, lim F X() =F X ( 0 ).! 0+ The net eecise sk tht this be shown moe genelly. Eecise 7.13. Pove the sttement concening the ight continuity of the distibution function fom the continuity popety of pobbility. Definition 7.14. A continuous ndom vible hs cumultive distibution function F X tht is diffeentible. So, distibution functions fo continuous ndom vibles incese smoothly. To show how this cn occu, we will develop n emple of continuous ndom vible. Emple 7.15. Conside dtbod hving unit dius. Assume tht the dt lnds ndomly unifomly on the dtbod. Let X be the distnce fom the cente. Fo 2 [0, 1], F X () =P {X pple } = e inside cicle of dius e of cicle = 2 1 2 = 2. 104 pobbility 1 0.8 0.6 0.4 0.2 0!0.2!0.4!0.6!0.8 0.0 0.2 0.4 0.6 0.8 1.0!1!1!0.8!0.6!0.4!0.2 0 0.2 0.4 0.6 0.8 1 0.0 0.5 1.0 Figue 7.2: (top) Dtbod. (bottom) Cumultive distibution function fo the dtbod ndom vible.

Thus, we hve the distibution function 8 < 0 if pple 0, F X () = 2 if 0 <pple 1, : 1 if >1. The fist line sttes tht X cnnot be negtive. The thid sttes tht X is t most 1, nd the middle lines descibes how X distibutes is vlues between 0 nd 1. Fo emple, F X 1 2 = 1 4 indictes tht with pobbility 1/4, the dt will lnd within 1/2 unit of the cente of the dtbod. Eecise 7.16. Find the pobbility tht the dt lnds between 1/3 unit nd 2/3 unit fom the cente. Eecise 7.17. Let the ewd Y fo though the dt be the invese 1/X of the distnce fom the cente. Find the cumultive distibution function fo Y. Eecise 7.18. An eponentil ndom vible X hs cumultive distibution function F X () =P {X pple } = 0 if pple 0, 1 ep( ) if >0. (7.3) fo some >0. Show tht F X hs the popeties of distibution function. Its vlue t cn be computed in R using the commnd pep(,0.1) fo > cuve(pep(,0.1),0,80) =1/10 nd dwn using pep(, 0.1) 0.0 0.2 0.4 0.6 0.8 1.0 0 20 40 60 80 Figue 7.3: Cumultive distibution function fo n eponentil ndom vible with =1/10. Eecise 7.19. The time until the net bus ives is n eponentil ndom vible with = 1/10 minutes. A peson wits fo bus t the bus stop until the bus ives, giving up when the wit eches 20 minutes. Give the cumultive distibution function fo T, the time tht the peson emins t the bus sttion nd sketch gph. Even though the cumultive distibution function is defined fo evey ndom vible, we will often use othe chcteiztions, nmely, the mss function fo discete ndom vible nd the density function fo continuous ndom vibles. Indeed, we typiclly will intoduce ndom vible vi one of these two functions. In the net two sections we intoduce these two concepts nd develop some of thei popeties. 105

7.4 Mss Functions Definition 7.20. The (pobbility) mss function of discete ndom vible X is f X () =P {X = }. The mss function hs two bsic popeties: f X () 0 fo ll in the stte spce. P f X() =1. The fist popety is bsed on the fct tht pobbilities e non-negtive. The second follows fom the obsevtion tht the collection C = {!; X(!) =} fo ll 2 S, the stte spce fo X, foms ptition of the pobbility spce. In Emple 7.8, we sw the mss function fo the ndom vible X tht is the sum of the vlues on two independent olls of fi dice. Emple 7.21. Let s mke tosses of bised coin whose outcomes e independent. We shll continue tossing until we obtin toss of heds. Let X denote the ndom vible tht gives the numbe of tils befoe the fist hed nd p denote the pobbility of heds in ny given toss. Then f X (0) = P {X =0} = P {H} = p f X (1) = P {X =1} = P {TH} =(1 f X (2) = P {X =2} = P {TTH} =(1 p)p p) 2 p... f X () =P {X = } = P {T TH} =(1 p) p So, the pobbility mss function f X () =(1 p) p. Becuse the tems in this mss function fom geometic sequence, X is clled geometic ndom vible. Recll tht geometic sequence c, c, c 2,...,c n hs sum s n = c + c + c 2 + + c n = c(1 n+1 ) 1 fo 6= 1. If < 1, then lim n!1 n =0nd thus s n hs limit s n!1. In this cse, the infinite sum is the limit Eecise 7.22. Estblish the fomul bove fo s n. c + c + c 2 + + c n + = lim n!1 s n = c 1. The mss function bove foms geometic sequence with the tio =1 nd b, p. Consequently, fo positive integes P { <Xpple b} = bx =+1 (1 p) p =(1 p) +1 p + +(1 p) b p = (1 p)+1 p (1 p) b+1 p 1 (1 p) =(1 p) +1 (1 p) b+1 We cn tke =0to find the distibution function fo geometic ndom vible. F X (b) =P {X pple b} =1 (1 p) b+1. Eecise 7.23. Give second wy to find the distibution function bove by eplining why P {X >b} =(1 p) b+1. 106

The mss function nd the cumultive distibution function fo the geometic ndom vible with pmete p =1/3 cn be found in R by witing > <-c(0:10) > f<-dgeom(,1/3) > F<-pgeom(,1/3) The initil d indictes density nd p indictes the pobbility fom the distibution function. > dt.fme(,f,f) f F 1 0 0.333333333 0.3333333 2 1 0.222222222 0.5555556 3 2 0.148148148 0.7037037 4 3 0.098765432 0.8024691 5 4 0.065843621 0.8683128 6 5 0.043895748 0.9122085 7 6 0.029263832 0.9414723 8 7 0.019509221 0.9609816 9 8 0.013006147 0.9739877 10 9 0.008670765 0.9826585 11 10 0.005780510 0.9884390 Note tht the diffeence in vlues in the distibution function F X () F X ( 1), giving the height of the jump in F X t, is equl to the vlue of the mss function. Fo emple, F X (3) F X (2) = 0.7037037 0.5555556 = 0.148148148 = f X (2). Eecise 7.24. Check tht the jumps in the cumultive distibution function fo the geometic ndom vible bove is equl to the vlues of the mss function. Eecise 7.25. Fo the geometic ndom vible bove, find P {X pple 3}, P {2 <Xpple 5}. P {X >4}. We cn simulte 100 geometic ndom vibles with pmete p = 1/3 using the R commnd geom(100,1/3). (See Figue 7.4.) Histogm of Histogm of Fequency 0 10 20 30 40 50 Fequency 0 1000 2000 3000 4000 5000 0 2 4 6 8 10 12 0 5 10 15 20 Figue 7.4: Histogm of 100 nd 10,000 simulted geometic ndom vibles with p =1/3. Note tht the histogm looks much moe like geometic seies fo 10,000 simultions. We shll see lte how this eltes to the lw of lge numbes. 107

7.5 Density Functions Definition 7.26. Fo X ndom vible whose distibution function F X hs deivtive. The function f X stisfying F X () = Z 1 f X (t) dt is clled the pobbility density function nd X is clled continuous ndom vible. By the fundmentl theoem of clculus, the density function is the deivtive of the distibution function. In othe wods, F X ( + ) F X () f X () = lim = F 0!0 X(). F X ( + ) F X () f X (). We cn compute pobbilities by evluting definite integls P { <Xpple b} = F X (b) F X () = The density function hs two bsic popeties tht mio the popeties of the mss function: Z b f X (t) dt. f X () 0 fo ll in the stte spce. R 11 f X() d =1. Retun to the dt bod emple, letting X be the distnce fom the cente of dtbod hving unit dius. Then, P { <Xpple + } = F X ( + ) F X () f X () =2 nd X hs density 8 < 0 if <0, f X () = 2 if 0 pple pple 1, : 0 if >1. Figue 7.5: The pobbility P { <Xpple b} is the e unde the density function, bove the is between y = nd y = b. Eecise 7.27. Let f X be the density fo ndom vible X nd pick numbe 0. Eplin why P {X = 0 } =0. Emple 7.28. Fo the eponentil distibution function (7.3), we hve the density function 0 if pple 0, f X () = e if >0. Emple 7.29. Density functions do not need to be bounded, fo emple, if we tke 8 < 0 if pple 0, f X () = pc : if 0 <<1, 0 if 1 pple. 108

Then, to find the vlue of the constnt c, we compute the integl So c =1/2. Fo 0 pple <bpple 1, 1= Z 1 0 P { <Xpple b} = c p t dt =2c p t 1 0 =2c. Z b 1 2 p t dt = p t b = p b Eecise 7.30. Give the cumultive distibution function fo the ndom vible in the pevious emple. Eecise 7.31. Let X be continuous ndom vible with density f X, then the ndom vible Y = X + b hs density f Y (y) = 1 y b f X (Hint: Begin with the definition of the cumultive distibution function F Y fo Y. Conside the cses >0 nd <0 septely.) p. 7.6 Joint Distibutions Becuse we will collect dt on sevel obsevtions, we must, s well, conside moe thn one ndom vible t time in ode to model ou epeimentl pocedues. Consequently, we will epnd on the concepts bove to the cse of multiple ndom vibles nd thei joint distibution. Fo the cse of two ndom vibles, X 1 nd X 2, this mens looking t the pobbility of events, P {X 1 2 B 1,X 2 2 B 2 }. Fo discete ndom vibles, tke B 1 = { 1 } nd B 2 = { 2 } nd define the joint pobbility mss function f X1,X 2 ( 1, 2 )=P {X 1 = 1,X 2 = 2 }. Fo continuous ndom vibles, we conside B 1 =( 1, 1 + 1 ] nd B 2 =( 2, 2 + 2 ] nd sk tht fo some function f X1,X 2, the joint pobbility density function to stisfy P { 1 <X 1 pple 1 + 1, 2 <X 2 pple 2 + 2 } f X1,X 2 ( 1, 2 ) 1 2. Emple 7.32. Genelize the notion of mss nd density functions to moe thn two ndom vibles. 7.6.1 Independent Rndom Vibles Mny of ou epeimentl potocols will be designed so tht obsevtions e independent. Moe pecisely, we will sy tht two ndom vibles X 1 nd X 2 e independent if ny two events ssocited to them e independent, i.e., P {X 1 2 B 1,X 2 2 B 2 } = P {X 1 2 B 1 }P {X 2 2 B 2 }. In wods, the pobbility tht the two events {X 1 2 B 1 } nd {X 2 2 B 2 } hppen simultneously is equl to the poduct of the pobbilities tht ech of them hppen individully. Fo independent discete ndom vibles, we hve tht f X1,X 2 ( 1, 2 )=P {X 1 = 1,X 2 = 2 } = P {X 1 = 1 }P {X 2 = 2 } = f X1 ( 1 )f X2 ( 2 ). In this cse, we sy tht the joint pobbility mss function is the poduct of the mginl mss functions. 109

Fo continuous ndom vibles, f X1,X 2 ( 1, 2 ) 1 2 P { 1 <X 1 pple 1 + 1, 2 <X 2 pple 2 + 2 } = P { 1 <X 1 pple 1 + 1 }P { 2 <X 2 pple 2 + 2 } f X1 ( 1 ) 1 f X2 ( 2 ) 2 = f X1 ( 1 )f X2 ( 2 ) 1 2. Thus, fo independent continuous ndom vibles, the joint pobbility density function is the poduct of the mginl density functions. f X1,X 2 ( 1, 2 )=f X1 ( 1 )f X2 ( 2 ) Eecise 7.33. Genelize the notion of independent mss nd density functions to moe thn two ndom vibles. Soon, we will be looking t n independent obsevtions 1, 2,..., n ising fom n unknown density o mss function f. Thus, the joint density is f( 1 )f( 2 ) f( n ). Genelly speking, the density function f will depend on the choice of pmete vlue. (Fo emple, the unknown pmete in the density function fo n eponentil ndom vible tht descibes the witing time fo bus.) Given the dt ising fom the n obsevtions, the likelihood function ises by consideing this joint density not s function of 1,..., n, but the s function of the pmete. We shll len how the study of the likelihood plys mjo ole in pmete estimtion nd in the testing of hypotheses. 7.7 Simulting Rndom Vibles One gol fo these notes is to povide the tools needed to design infeentil pocedues bsed on sound pinciples of sttisticl science. Thus, one of the vey impotnt uses of sttisticl softwe is the bility to genete pseudodt to simulte the ctul dt. This povides the oppotunity to test nd efine methods of nlysis in dvnce of the need to use these methods on genuine dt. This equies tht we eploe the popeties of the dt though simultion. Fo mny of the fequently used fmilies of ndom vibles, R povides commnds fo thei simultion. We shll emine these fmilies nd thei popeties in Topic 9, Emples of Mss Functions nd Densities. Fo othe cicumstnces, we will need to hve methods fo simulting sequence of independent ndom vibles tht possess common distibution. We fist conside the cse of discete ndom vibles. 7.7.1 Discete Rndom Vibles nd the smple Commnd The smple commnd is used to cete simple nd sttified ndom smples. Thus, if we ente sequence, smple(,40) chooses 40 enties fom in such wy tht ll choices of size 40 hve the sme pobbility. This uses the defult R commnd of smpling without eplcement. We cn use this commnd to simulte discete ndom vibles. To do this, we need to give the stte spce in vecto nd mss function f. The cll fo eplce=true indictes tht we e smpling with eplcement. Then to give smple of n independent ndom vibles hving common mss function f, we use smple(,n,eplce=true,pob=f). Emple 7.34. Let X be descibed by the mss function 1 2 3 4 f X () 0.1 0.2 0.3 0.4 Then to simulte 50 independent obsevtions fom this mss function: > <-c(1,2,3,4) > f<-c(0.1,0.2,0.3,0.4) > sum(f) 110

[1] 1 > dt<-smple(,50,eplce=true,pob=f) > dt [1] 1 4 4 4 4 4 3 3 4 3 3 2 3 3 3 4 4 3 3 2 4 1 3 3 4 2 3 3 3 1 2 4 3 2 3 4 4 4 4 2 4 1 [43] 2 3 4 4 1 4 3 4 Notice tht 1 is the lest epesented vlue nd 4 is the most epesented. If the commnd pob=f is omitted, then smple will choose unifomly fom the vlues in the vecto. Let s check ou simultion ginst the mss function tht geneted the dt. (Notice the double equl sign, ==.) Fist, ecount the obsevtions tht tke on ech possible vlue fo. We cn mke tble. > tble(dt) dt 1 2 3 4 5 7 18 20 o use the counts to detemine the simulted popotions. > counts<-ep(0,m()-min()+1) > fo (i in min():m()){counts[i]<-length(dt[dt==i])} > simpob<-counts/(sum(counts)) > dt.fme(,f,simpob) f simpob 1 1 0.1 0.10 2 2 0.2 0.14 3 3 0.3 0.36 4 4 0.4 0.40 Eecise 7.35. Simulte the sums on ech of 20 olls of pi of dice. Repet this fo 1000 olls nd compe the simultion with the ppopite mss function. 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 Figue 7.6: Illustting the Pobbility Tnsfom. Fist simulte unifom ndom vibles u 1,u 2,...,u n on the intevl [0, 1]. About 10% of the ndom numbes should be in the intevl [0.3, 0.4]. This coesponds to the 10% of the simultions on the intevl [0.28, 0.38] fo ndom vible with distibution function F X shown. Similly, bout 10% of the ndom numbes should be in the intevl [0.7, 0.8] which coesponds to the 10% of the simultions on the intevl [0.96, 1.51] fo ndom vible with distibution function F X, These vlues on the -is cn be obtined fom tking the invese function of F X, i.e., i = F 1 X (u i). 111

7.7.2 Continuous Rndom Vibles nd the Pobbility Tnsfom If X continuous ndom vible with density f X tht is positive eveywhee in its domin, then the distibution function F X () =P {X pple } is stictly incesing. In this cse F X hs invese function F 1 X, known s the quntile function. Eecise 7.36. F X () pple u if nd only if pple F 1 X (u). The pobbility tnsfom follows fom n nlysis of the ndom vible U = F X (X) Note tht F X hs nge fom 0 to 1. It cnnot tke vlues below 0 o bove 1. Thus, U tkes on vlues between 0 nd 1. Thus, F U (u) =0fo u<0 nd F U (u) =1fo u 1. Fo vlues of u between 0 nd 1, note tht P {F X (X) pple u} = P {X pple F 1 X (u)} = F X(F 1 X (u)) = u. Thus, the distibution function fo the ndom vible U, 8 < 0 u<0, F U (u) = u 0 pple u<1, : 1 1 pple u. If we cn simulte U, we cn simulte ndom vible with distibution F X vi the quntile function X = F 1 X (U). (7.4) Tke deivtive to see tht the density 8 < 0 u<0, f U (u) = 1 0 pple u<1, : 0 1 pple u. Becuse the ndom vible U hs constnt density ove the intevl of its possible vlues, it is clled unifom on the intevl [0, 1]. It is simulted in R using the unif commnd. The identity (7.4) is clled the pobbility tnsfom. This tnsfom is illustted in Figue 7.6. We cn see how the pobbility tnsfom woks in the following emple. Emple 7.37. Fo the dt bod, fo between 0 nd 1, the distibution function u = F X () = 2 nd thus the quntile function = F 1 X (u) =p u. We cn simulte independent obsevtions of the distnce fom the cente X 1,X 2,...,X n of the dt bod by simulting independent unifom ndom vibles U 1,U 2,...U n nd tking the quntile function X i = p U i. 112 pobbility 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 Figue 7.7: The distibution function (ed) nd the empiicl cumultive distibution function (blck) bsed on 100 simultions of the dt bod distibution. R commnds given below.

> u<-unif(100) > <-sqt(u) > d<-seq(0,1,0.01) > plot(sot(),1:length()/length(), type="s",lim=c(0,1),ylim=c(0,1), lb="",ylb="pobbility") > p(new=true) > plot(d,dˆ2,type="l",lim=c(0,1),ylim=c(0,1),lb="",ylb="",col="ed") Eecise 7.38. If U is unifom on [0, 1], then so is V =1 U. Sometimes, it is esie to simulte X using F 1 X (V ). Emple 7.39. Fo n eponentil ndom vible, set u = F X () =1 ep( ), nd thus = 1 ln(1 u) Consequently, we cn simulte independent eponentil ndom vibles X 1,X 2,...,X n by simulting independent unifom ndom vibles V 1,V 2,...V n nd tking the tnsfom R ccomplishes this diectly though the ep commnd. X i = 1 ln V i. 7.8 Answes to Selected Eecises 7.2. The sum, the mimum, the minimum, the diffeence, the vlue on the fist die, the poduct. 7.3. The oll with the fist H, the numbe of T, the longest un of H, the numbe of T s fte the fist H. 7.4. b10 n c/10 n 7.6. A common wy to show tht two events A 1 nd A 2 e equl is to pick n element! 2 A 1 nd show tht it is in A 2. This poves A 1 A 2. Then pick n element! 2 A 2 nd show tht it is in A 1, poving tht A 2 A 1. Tken togethe, we hve tht the events e equl, A 1 = A 2. Sometimes the logic needed in showing A 1 A 2 consist not solely of implictions, but the of equivlent sttements. (We cn indicte this with the symbol ().) In this cse we cn combine the two pts of the gument. Fo this eecise, s the lines below show, this is successful sttegy. We follow n bity outcome! 2. 1.! 2{X 2 B} c ()! /2{X 2 B} ()X(!) /2 B () X(!) 2 B c ()! 2{X 2 B c }. Thus, {X 2 B} c = {X 2 B c }. 2.! 2 S i {X 2 B i}()! 2{X 2 B i } fo some i () X(!) 2 B i fo some i () X(!) 2 S i B i ()! 2{X 2 S i B}. Thus, S i {X 2 B i} = {X 2 S i B}. The identity with intesection is simil with fo ll insted of fo some. 3. We must show tht the union of the C i is equl to the stte spce S nd tht ech pi e mutully eclusive. Fo this () Becuse B i e ptition of, S i B i =, nd [ C i = [ {X 2 B i } = {X 2 [ i i i B i } = {X 2 } = S, the stte spce. 113

(b) Fo i 6= j, B i \ B j = ;, nd C i \ C j = {X 2 B i }\{X 2 B j } = {X 2 B i \ B j } = {X 2 ;} = ;. 7.7. Let s check the thee ioms. Ech veifiction is bsed on the coesponding iom fo the pobbility P. 1. Fo ny subset B, P X (B) =P {X 2 B} 0. 2. Fo the smple spce S, P X (S) =P {X 2 S} = P ( ) = 1. 3. Fo mutully eclusive subsets B i,i =1, 2,, we hve by the eecise bove the mutully eclusive events {X 2 B i },i=1, 2,. Thus,! ( )! [ 1 1[ 1[ 1X 1X P X B i = P X 2 B i = P {X 2 B i } = P {X 2 B i } = P X (B i ). i=1 i=1 7.9. Fo thee tosses of bised coin, we hve i=1 i=1 0 1 2 3 P {X = } (1 p) 3 3p(1 p) 2 3p 2 (1 p) p 3 Thus, the cumultive distibution function, 8 0 fo <0, >< (1 p) 3 fo 0 pple <1, F X () = (1 p) 3 +3p(1 p) 2 =(1 p) 2 (1 + 2p) fo 1 pple <2, (1 p) >: 2 (1 + 2p)+3p 2 (1 p) =1 p 3 fo 2 pple <3, 1 fo 3 pple 7.10. Fom the emple in the section Bsics of Pobbility, we know tht To plot the distibution function, we use, 0 1 2 3 P {X = } 0.41353 0.43588 0.13765 0.01294 > hets<-c(0:3) > f<-choose(13,hets)*choose(39,3-hets)/choose(52,3) > (F<-cumsum(f)) [1] 0.4135294 0.8494118 0.9870588 1.0000000 > plot(hets,f,ylim=c(0,1),type="s") Thus, the cumultive distibution function, 8 0 fo <0, >< 0.41353 fo 0 pple <1, F X () = 0.84941 fo 1 pple <2, 0.98706 fo 2 pple <3, >: 1 fo 3 pple 7.11. The cumultive distibution function fo Y, F Y (y) =P {Y pple y} = P {X 3 pple y} = P {X pple 3p y} = F X ( 3p y). 7.12. To veify the thee popeties fo the distibution function: F 0.0 0.2 0.4 0.6 0.8 1.0 114 i=1 0.0 0.5 1.0 1.5 2.0 2.5 3.0 hets

1. Let n! 1be decesing sequence. Then 1 > 2 > Thus, {X pple 1 } {X pple 2 } P {X pple 1 } P {X pple 2 } Fo ech outcome!, eventully, fo some n, X(!) > n, nd!/2{x pple n } nd consequently no outcome! is in ll of the events {X pple n } nd 1\ {X pple n } = ;. n=1 Now, use the second continuity popety of pobbilities. 2. Let n!1be n incesing sequence. Then 1 < 2 < Thus, {X pple 1 } {X pple 2 }. P {X pple 1 }pplep {X pple 2 }pple. Fo ech outcome!, eventully, fo some n, X(!) pple n, nd 1[ {X pple n } =. n=1 Now, use the fist continuity popety of pobbilities. 3. Let 1 < 2, then {X pple 1 } {X pple 2 } nd by the monotonicity ule fo pobbilities P {X pple 1 }pplep {X pple 2 }, o witten in tems of the distibution function, F X ( 1 ) pple F X ( 2 ) 7.13. Let n! 0 be stictly decesing sequence. Then 1 > 2 > 1\ {X pple 1 } {X pple 2 }, {X pple n } = {X pple 0 }. (Check this lst equlity.) Then P {X pple 1 } P {X pple 2 }. Now, use the second continuity popety of pobbilities to obtin lim n!1 F X ( n )=lim n!1 P {X pple n } = P {X pple 0 } = F X ( 0 ). Becuse this holds fo evey stictly decesing sequencing sequence with limit 0, we hve tht n=1 lim F X() =F X ( 0 ).! 0+ 7.15. Using the identity in (7.2), we hve 1 P 3 <Xpple 2 3 = F 2 3 1 F = 4 3 9 1 9 = 3 9 = 1 3. Check Eecise 7.22 to see tht the nswe does not depend on whethe o not the endpoints of the intevl e included. 7.17. Using the eltion Y =1/X, we find tht the distibution function fo Y, F Y (y) =P {Y pple y} = P {1/X pple y} = P {X 1/y} =1 P {X <1/y} =1 Thus uses the fct tht P {X =1/y} =0. 7.18. We use the fct tht the eponentil function is incesing, nd tht lim u!1 ep( u) =0. Using the numbeing of the popeties bove 115 1 y 2.

1. Becuse F X () =0fo ll <0, lim! 1 F X () =0. 2. lim!1 ep( ) =0. Thus, lim!1 F X () =lim!1 1 ep( ) =1. 3. Fo <0, F X is constnt, F X (0) = 0. Fo 0, note tht ep( ) is decesing. Thus, F X () = 1 ep( ) is incesing. Consequenlty, the distibution function F X is non-decesing. 7.19. The distibution function hs the gph shown in Figue 7.8. F 0.0 0.2 0.4 0.6 0.8 1.0 0 20 40 60 80 Figue 7.8: Cumultive distibution function fo n eponentil ndom vible with =1/10 nd jump t =20. The fomul 8 < 0 if <0, F T () =P {X pple } = 1 ep( /10) if 0 pple <20, : 1 if 20 pple. 7.22. Fo 6= 1, wite the epessions fo s n nd s n nd subtct. Notice tht most of the tems cncel. Now divide by 1 s n = c+ c +c 2 + + c n s n = c +c 2 + + c n +c n+1 (1 )s n = c c n+1 = c(1 n+1 ) to obtin the fomul. 7.23 The event {X >b} is the sme s hving the fist b +1coin tosses tun up tils. Thus, the outcome is b +1 independent events ech with pobbility 1 p. Consequently, P {X >b} =(1 p) b+1. 7.25. P {X pple 3} = F X (3) =.8024691, P {2 <Xpple 5} = F X (5) F X (2) = 0.8683128 0.5555556 = 0.3127572, nd P {X >4} 1 F X (4) = 1 0.8024691 = 0.1975309. 7.27. Let f X be the density. Then 0 pple P {X = 0 }pplep { 0 <Xpple + } = Now the integl goes to 0 s! 0. So, we must hve P {X = 0 } =0. 116 Z 0+ 0 f X () d.

7.28. Becuse the density is non-negtive on the intevl [0, 1], F X () =0if <0 nd F X () =1if 1. Fo between 0 nd 1, Z 1 2 p t dt = p t = p. 0 Thus, 8 < 0 p if pple 0, F X () = if 0 <<1, : 1 if 1 pple. 0 7.31. The ndom vible Y hs distibution function F Y (y) =P {Y pple y} = P {X + b pple y} = P {X pple y b}. Fo >0 F Y (y) =P X pple y b y b = F X. Now tke deivtive nd use the chin ule to find the density y b 1 f Y (y) =FY 0 (y) =f X = 1 y b f X. Fo <0 Now the deivtive F Y (y) =P X y b y b =1 F X. y b 1 f Y (y) =FY 0 (y) = f X = 1 y f X b. 7.32. The joint density (mss function) fo X 1,X 2,...,X n f X1,X 2,...,X n ( 1, 2,..., n )=f X1 ( 1 )f X2 ( 2 ) f Xn ( n ) is the poduct of the mginl densities (mss functions). 7.35. Hee is the R code. > <-c(2:12) > [1] 2 3 4 5 6 7 8 9 10 11 12 > f<-c(1,2,3,4,5,6,5,4,3,2,1)/36 > sum(f) [1] 1 > (twodice<-smple(,20,eplce=true,pob=f)) [1] 9 7 3 9 3 6 9 5 5 5 5 10 10 12 9 8 6 8 11 8 > twodice<-smple(,1000,eplce=true,pob=f) > counts<-ep(0,m()-min()+1) > fo (i in min():m()){counts[i]<-length(twodice[twodice==i])} > feq=counts/(sum(counts)) > dt.fme(,f,feq[min():m()]) f feq.min...m... 1 2 0.02777778 0.031 2 3 0.05555556 0.054 117

F 0.0 0.2 0.4 0.6 0.8 1.0 2 4 6 8 10 12 Figue 7.9: Sum on two fi dice. The empiicl cumultive distibution function fom the simultion (in blck) nd the cumultive distibution function (in ed) e shown fo Eecise 7.31. 3 4 0.08333333 0.065 4 5 0.11111111 0.096 5 6 0.13888889 0.120 6 7 0.16666667 0.167 7 8 0.13888889 0.157 8 9 0.11111111 0.121 9 10 0.08333333 0.098 10 11 0.05555556 0.058 11 12 0.02777778 0.033 We lso hve plot to compe the empiicl cumultive distibution function fom the simultion with the cumultive distibution function. > plot(sot(twodice),1:length(twodice)/length(twodice),type="s",lim=c(2,12), ylim=c(0,1),lb="",ylb="") > p(new=true) > plot(,f,type="s",lim=c(2,12),ylim=c(0,1),col="ed") 7.39. F X is incesing nd continuous, so the set {; F X () pple u} is the intevl ( 1,F 1 X (u)]. In ddition, is in this invevl pecisely when pple F 1 X (u). 7.40. Let s find F V. If v<0, then 0 pple P {V pple v} pplep {V pple 0} = P {1 U pple 0} = P {1 pple U} =0 becuse U is neve gete thn 1. Thus, F V (v) =0Similly, if v 1, 1 P {V pple v} P {V pple 1} = P {1 U pple 1} = P {0 pple U} =1 becuse U is lwys gete thn 0. Thus, F V (v) =1. Fo 0 pple v<1, F V (v) =P {V pple v} = P {1 U pple v} = P {1 v pple U} =1 P {U <1 v} =1 (1 v) =v. This mtches the distibution function of unifom ndom vible on [0, 1]. 118