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

How to create an Android mobile app with a deep learning AI model ?

Creating an Android mobile app with a deep learning AI model involves several key steps:…

6 days ago

Download source files for R Machine learning

Click here to go to source files for R Machine Learning

1 month ago

Python Machine Learning Source Files

Click here to download Python Machine Learning Source Files !

2 months ago

Install PyTorch on Windows

PyTorch is a deep learning package for machine learning, or deep learning in particular for…

3 months ago

Topic Modeling using Latent Dirichlet Allocation with Python

Topic modeling is a subcategory of unsupervised machine learning method, and a clustering task in…

3 months ago

Document sentiment classification using bag-of-words in Python

For online Python training registration, click here ! Sentiment classification is a type of machine…

4 months ago