Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Shawn McAdam (ssm259)
Binomial Distribution Calculator
Commits
3575a541
Commit
3575a541
authored
Jun 11, 2020
by
Shawn Samuel Carl McAdam
Browse files
Added better comments
parent
72538ba6
Changes
2
Hide whitespace changes
Inline
Side-by-side
bin_dfs.c
View file @
3575a541
#include
<inttypes.h>
// uint64_t
#include
<stdio.h>
#include
<stdlib.h>
#include
"bin_dfs.h"
// private helper functions
...
...
@@ -25,6 +23,8 @@ long double cdf(uint64_t k, uint64_t n, long double p){
}
// Can't do tail recursion here because the intermediate products can get
// far larger than LDBL_MAX
long
double
pmf_helper
(
uint64_t
k
,
uint64_t
n
,
long
double
p
){
// work through our k's then work through our n's.
if
(
n
==
0
)
...
...
bin_dfs.h
View file @
3575a541
...
...
@@ -19,11 +19,12 @@ long double pmf(uint64_t k, uint64_t n, long double p);
* Purpose:
* Recusively sum up the probabilities for each i<=n
* Assumptions:
*
i
<=n
*
k
<=
n
* Returns:
* P(X<=i) where X~bin(n, p)
* P(X<=k) where X~bin(n, p)
* ie, \sum_{j=0}^k pmf(j, n, p)
*/
long
double
cdf
(
uint64_t
i
,
uint64_t
n
,
long
double
p
);
long
double
cdf
(
uint64_t
k
,
uint64_t
n
,
long
double
p
);
#endif // DIST_FUNCT_H
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment