binomial¶
Binomial Distribution¶
A binomial distribution class, derived from a Udacity exercise template.
- final class boring_math.probability_distributions.distributions.binomial.Binomial(p: float = 0.5, n: int = 20)¶
Class for visualizing data as Binomial distributions.
The binomial distribution represents the number of events with probability
phappening innnumbers of trials.Attributes (some inherited):
mean(float) representing the mean value of the distributionstdev(float) representing the standard deviation of the distributiondataextracted from a data file (taken to be a population)p(float) representing the probability of an event occurringn(int) the total number of trials
- __add__(other: Self) Self¶
Add together two Binomial distributions with equal p.
- __init__(p: float = 0.5, n: int = 20)¶
- __repr__() str¶
Return repr(self).
- __str__() str¶
Return str(self).
- calculate_mean() float¶
Calculate the mean from p and n
- calculate_stdev() float¶
Calculate the standard deviation using p and n
- cdf(kf: float) float¶
Binomial cumulative probability distribution function.
- pdf(kf: float) float¶
Binomial probability distribution function.
- plot_bar_data() None¶
Produce a bar-graph of the data using the matplotlib pyplot library.
- plot_bar_pdf() tuple[list[int], list[float]]¶
Function to plot the pdf of the binomial distribution.
- Returns:
A tuple containing
list[int]: x values used for the pdf plot
list[float]: y values used for the pdf plot