binomial¶
Binomial Distribution¶
A binomial distribution class, derived from a Udacity exercise template.
- final class boring_math.probability_distributions.distributions.binomial.Binomial¶
Bases:
DiscreteDistClass for visualizing Binomial distributed data.
A 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
- __init__(p: float = 0.5, n: int = 20)¶
- pdf(kf: float) float¶
Binomial probability distribution function.
- cdf(kf: float) float¶
Binomial cumulative probability distribution function.
- calculate_mean() float¶
Calculate the mean from p and n
- calculate_stdev() float¶
Calculate the standard deviation using p and n
- replace_stats_from_dataset(dset: DataSet) tuple[float, int]¶
Function to calculate p and n from a data set.
Where the read in data set is taken as the population.
- 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
- __add__(other: Self) Self¶
Add together two Binomial distributions with equal p.
- __repr__() str¶
Return repr(self).
- __str__() str¶
Return str(self).