knitr::opts_chunk$set(collapse = T, comment = "#>") library(binomial) library(ggplot2)
The package "binomial" is a method to calculate the various attributes of a binomial distribution given parameters.
To calculate the number of comibnations in which k successes can occur in n trials, we use the bin_choose() function:
bin_choose(n = 5, k = 2)
To create a binomial random variable with k trials and probability prob, we use the function bin_variable():
variable = bin_variable(trials = 5, prob = 0.5)
To calculate the probability of k successes, each independent with probability prob, on n repeated trials, we use the bin_probability() function:
bin_probability(success = 2, trials = 5, prob = 0.5)
To calculate the binomial distribution of k trials and probability prob, we use the bin_distribution() function:
distribution = bin_distribution(trials = 5, prob = 0.5) distribution
To plot the above calculated binomial distribution, we use the function plot.bindis():
plot.bindis(distribution)
To find the cumulative distribution of k trials and probability prob, we use the function bin_cumulative():
cumulative_distribution = bin_cumulative(trials = 5, prob = 0.5) cumulative_distribution
To plot the above calculated cumulative distribution, we use the function plot.bincum():
plot.bincum(cumulative_distribution)
To create the summary of a binomial variable, we use the function summary.binvar():
summary.binvar(variable)
To displat the summary of a binomial variable, we use the function print.summary.binvar():
print.summary.binvar(variable)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.