STD has many distributions, that apparently are used to generate pseudo random variables, see e.g. below code that generates and outputs some negative binomial distributed numbers.
Now this might mean that internally, there is code that computes the CDF and or PDF of the negative binomial distribution, i.e. the probability that the random variable takes on a certain value, e.g. 6. Is there a way to output that probability? If yes, how? I know I could run my own code for that, but I'd rather not do that if it there is some way to get the probabilities from std.
If possible, same question for other distributions, e.g. CDF of gamma distribution.
int main()
{
std::negative_binomial_distribution<int> negBin{ 5,0.5 };//Negative binomial distribution
std::mt19937 RNG(260783);//Random generator
for (size_t i = 0; i < 4; i++)
{
std::cout << negBin(RNG) << std::endl;
}
return 0;
}
y = binocdf( x , n , p ) computes a binomial cumulative distribution function at each of the values in x using the corresponding number of trials in n and the probability of success for each trial in p .
Given a sequence of r Bernoulli trials with probability of success p, X follows a negative binomial distribution if X = k is the number of trials needed to get to the rth success. Pdf of X. P(X = k) = (k - 1. r - 1.
BinomPDF and BinomCDF are both functions to evaluate binomial distributions on a TI graphing calculator. Both will give you probabilities for binomial distributions. The main difference is that BinomCDF gives you cumulative probabilities.
(the negative binomial coefficient is the left one). By definition, (−rk)∗(−1)k=(−1)k(−r)(−r−1)⋯(−r−k+1)k! =(−1)k+1r(r+1)⋯(r+k−1)k!
The standard doesn't specify how an implementation should implement the distribution, other than that sampling from it should take an amortised constant number of samples from the Generator.
None of the members provide either the CDF or PDF
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With