Rust repo that provides a robust poisson-rate hypothesis test, returning p -values for the probability that two observed poisson data sets are different. The intended use of this single-function library is to test whether two events are occuring at the same rate.
I use it in kda-tools for hypothesis testing loadouts in video games.
Here's a few examples, see more in the docs
```rust use claim::{assertlt,assertgt}; use poissonratiotest::{onetailedratio,twotailedrates_equal};
//create data where rate1 == 1/2 * rate2
let occurancesone = vec![1,0,1,0,1,0];
let occurancestwo = vec![1,1,1,1,0,2];
let n1 = occurancesone.len() as f64;
let n2 = occurancestwo.len() as f64;
let sum1 = occurancesone.iter().sum::
//test hypothesis that r1/r2 > 1/2 let p = onetailedratio(sum1, n1, sum2, n2, 0.5); asserteq!(p, 0.50); //<-- nope //let's test the neighbordhood around that let p = onetailedratio(sum1, n1, sum2, n2, 0.49999 ); assertgt!(p, 0.49); //<-- still nope
//Two sided test. What is the likelihood of seeing the data we got //given that r1/r2 == 1/2? let phalf = onetailedratio(sum1, n1, sum2, n2, 0.49999); //other side let pdouble = onetailedratio(sum2, n2, sum1, n1, 2.0001); //just about 1.0! assertgt!(2.0*phalf.min(p_double),0.99);
//we know they are not equal, but can we prove it in general? let mut pdouble = twotailedratesequal(sum2, n2, sum1, n1); //note: pdouble is in [.15,.25] assertlt!(pdouble,0.25);//<--looking unlikely... maybe more data is required assertgt!(p_double,0.15);//<--looking unlikely... maybe more data is required
//get more of the same data
let trial2one = vec![1,0,1,0,1,0,1,0,1,0,1,0,1,0];
let trial2two = vec![1,1,1,1,0,2,0,2,1,1,0,2,1,1];
let t2n1 = trial2one.len() as f64;
let t2n2 = trial2two.len() as f64;
let t2sum1 = trial2one.iter().sum::