static int cdf_dpois (lua_State *L) { /* stack should contain s and xlam */ lua_Number s = luaL_checknumber(L, 1); lua_Number xlam = luaL_checknumber(L, 2); lua_Number d; check_pois(L, 1, s, xlam); d = s+1; d = exp(s*log(xlam)-xlam-dlngam(&d)); lua_pushnumber(L, d); return 1; }
static int stat_ppois (lua_State *L) { /* stack should contain s and xlam */ lua_Number s = luaL_checknumber(L, 1); lua_Number xlam = luaL_checknumber(L, 2); lua_Number p, q, bound; int which = 1; int status; check_pois(L, 1, s, xlam); cdfpoi(&which, &p, &q, &s, &xlam, &status, &bound); check_status(L, status, bound); lua_pushnumber(L, p); return 1; }
static int cdf_qpois (lua_State *L) { /* stack should contain p and xlam */ lua_Number p = luaL_checknumber(L, 1); lua_Number xlam = luaL_checknumber(L, 2); int si = 0; check_pois(L, 2, p, xlam); if (p==1) { lua_pushnumber(L, HUGE_VAL); return 1; } if (p>0) { lua_Number q = 1-p; lua_Number s, bound; int which = 2; int status; cdfpoi(&which, &p, &q, &s, &xlam, &status, &bound); check_status(status, bound); lua_number2int(si, s); } lua_pushinteger(L, si); return 1; }