﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
975	Error in DistPoissonInv	imendez	Víctor de Buen Remiro	"Hi,

I think the function DistPoissonInv does not work right.
If X is a variable following a Poisson distribution with lambda parameter equal to, for example, 1.1, we have that:

{{{
Real lambda = 1.1;
Real prob0 = DistPoisson(0, lambda); // prob0 = 0.332871
Real prob1 = DistPoisson(1, lambda); // prob1 = 0.699030
Real prob2 = DistPoisson(2, lambda); // prob2 = 0.900416
}}}

where probZ is the probability of X = z.
Then, using the inverse probability distribution:

{{{
Real pois0.1 = DistPoissonInv(0.1, lambda); // prob0.1 = 0
Real pois0.4 = DistPoissonInv(0.4, lambda); // prob0.4 = 0 ¡¡¡!!!
Real pois0.8 = DistPoissonInv(0.8, lambda); // prob0.8 = 1 ¡¡¡!!!
}}}

Note that pois0.1 takes the right value, but pois0.4 and pois0.8 should be, respectively, 1 and 2.

In fact, when simulating a Poisson distribution by the inverse transform sample method, the average of the simulated sample is not equal to the lambda parameter used:

{{{
// Real lambda = 1.1;
Set poisson_sim = For(1, 1000, Real(Real k){
  Real rnd = Rand(0, 1);
  DistPoissonInv(rnd, lambda)
});
Real poisson_avg = SetAvr(poisson_sim);
}}}

In this case, poisson_avg is approximately equal to 0.72, when it should be equal to 1.1 (lambda)

Regards
"	defect	closed	normal	Numerical methods	Math	2.0.1	major	fixed	distribution, sample, inverse, probability	
