Certainly! The binomial distribution is commonly used to model the probability of a certain number of successes in a fixed number of independent Bernoulli trials. Here's an example code snippet in Python to calculate the probability mass function (PMF) and cumulative distribution function (CDF) of the binomial distribution:
import scipy.stats as stats
n = 10 # Number of trials
p = 0.5 # Probability of success
# Calculate PMF
x = 5 # Number of successes
pmf = stats.binom.pmf(x, n, p)
print("Probability mass function (PMF):", pmf)
# Calculate CDF
cdf = stats.binom.cdf(x, n, p)
print("Cumulative distribution function (CDF):", cdf)
In this example, we calculate the PMF and CDF of a binomial distribution with 10 trials and a success probability of 0.5. We then compute the probability of getting exactly 5 successes (PMF) and the probability of getting 5 or fewer successes (CDF).