R: Geometric Distribution
d => density/mass function
p => probability (cumulative distribution function) P(X <= x)
q => quantiles, given q, the smallest x such that P(X <= x) > q
r => random number generation
p => probability (cumulative distribution function) P(X <= x)
q => quantiles, given q, the smallest x such that P(X <= x) > q
r => random number generation
#####in R the geometric distribution is the number of failures before a success, not the number of trials including the success.
### F
dgeom(1,.5) # dgeom(x, prob)
pgeom(1, .5) # pgeom(q, prob)
qgeom(1, 0.5) # qgeom(p, prob)
random.geom=rgeom(10, .5)+1 # rgeom(n, prob)
start=.01
end=.99
by=.1
random.probabilities=seq(start, end, by)
random.probabilities
l.random.geom=length(random.probabilities) #
for( i in 1:l.random.geom){
random.geom=rgeom(100, random.probabilities[i])+1
hist(random.geom, col=rainbow(10))
}
### F
dgeom(1,.5) # dgeom(x, prob)
pgeom(1, .5) # pgeom(q, prob)
qgeom(1, 0.5) # qgeom(p, prob)
random.geom=rgeom(10, .5)+1 # rgeom(n, prob)
start=.01
end=.99
by=.1
random.probabilities=seq(start, end, by)
random.probabilities
l.random.geom=length(random.probabilities) #
for( i in 1:l.random.geom){
random.geom=rgeom(100, random.probabilities[i])+1
hist(random.geom, col=rainbow(10))
}