Geometirc - avoid any confusion, I have written a function...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Geometric Distribution A discrete random variable is said to have a geometric distribution if The experiment involves independent and identical trials. Each trial has two possible outcomes, success and failure. The probability of success on each trial is the same, p . Therefore, the probability of failure on each trial is 1 - p = q . The experiment is repeated until the Frst success occurs. The random variable Y is deFned as the number of the trial on which the Frst success occurs. The parameter for the geometric random variable Y is the probability of success on each trial p . The probability distribution function of the geometric random variable Y is p ( y ) = p (1 - p ) y - 1 for y = 1 , 2 , . . . The theoretical mean of the geometric random variable Y is μ = E ( Y ) = 1 p The variance of the geometric random variable Y is σ 2 = V ( Y ) = 1 - p p 2 Working with geometric random variables in R. The built-in function for the geometric distribution is di±erent from the one in your textbook. To
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: avoid any confusion, I have written a function in R called dgeo which will calculate probabilities for the geometric distribution that will match your textbook. Before you use R to calculate the probabilities for the geometric distribution, you need to type in the following function. dgeo<- function(y,p){p*(1-p)^(y-1)} To Fnd a probability P ( Y = y ) = p ( y ) for a single value y , the command in R is dgeo(y,p) To Fnd the probability P ( Y y ), use the sum command to add up all p ( y ) values for y between and including 1 and y . sum(dgeo(1:y,p)) To Fnd the probability P ( y 1 Y y 2 ), use the sum command to add up all p ( y ) values for y between and including y 1 and y 2 . sum(dgeo(y1:y2,p)) To Fnd the probability P ( Y y ) = 1-P ( Y < y ) = 1-P ( Y y-1), use the sum command to Fnd P ( Y y-1) and subtract this value from 1. 1 - sum(dgeo(1:y-1,p)) 1...
View Full Document

Ask a homework question - tutors are online