How to calculate Geometric distribution probabilities in R

We provide effective and economically affordable online training courses for R and Python, click here for more details and course registration !

Geometric distribution is to model the random trial number X until a first success, in Bernoulli trial experiments, with constant success rate p. The probability of x can be calculated as

Geometric Probability

Geometric distribution is a special case of Negative Binomial distribution, which models the X trial is the n success trial.

R programming language provides function dgeom() for geometric probability computation. Next example shows the geometric probabilities for different number of X between 1 and 8 until a success trial in Bernoulli experiments, with success rate p = 0.15 for a single trial.

# create a vector for X series values
xtrial <- seq(1, 8, by = 1)    
# Using dgeom() function to calculate probabilities for each value of Xtrial 
#probability of x trials until getting a success
probtrial <- dgeom(xtrial, prob = 0.15)    
probtrial
#output
[1] 0.12750000 0.10837500 0.09211875 0.07830094 0.06655580 0.05657243
[7] 0.04808656 0.04087358
# Plot probabilities
plot(probtrial)  
Geometric Probabilities

For getting more knowledge of R and a preview of our training course, you can watch R tutorial videos on our YouTube channel !

wilsonzhang746

Recent Posts

Download R Course source files

Click here to download R Course source files !

2 months ago

Download Python Course source files

Click here to download Python Course Source Files !

2 months ago

How to create a data frame from nested dictionary with Pandas in Python

For online Python training registration, click here ! Pandas provides flexible ways of generating data…

5 months ago

How to delete columns of a data frame in Python

For online Python training registration, click here ! Data frame is the tabular data object…

5 months ago

Using isin() to check membership of a data frame in Python

Click her for course registration ! When a data frame in Python is created via…

5 months ago

How to assign values to Pandas data frame in Python

We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental…

5 months ago