4 #define TWEEDIE_DROP 37.0
6 #define TWEEDIE_INCRE 5
8 #define TWEEDIE_NTERM 20000
23 Float tweedie_logW(
double y, Float& phi, Float& p){
24 bool ok = (0 < y) && (0 < phi) && (1 < p) && (p < 2);
27 Float p1 = p - 1.0, p2 = 2.0 - p;
28 Float a = - p2 / p1, a1 = 1.0 / p1;
29 Float
cc,
w, sum_ww = 0.0;
30 double ww_max = -INFINITY ;
37 cc = a *
log(p1) -
log(p2);
39 logz = - a *
log(y) - a1 *
log(phi) +
cc;
43 cc = logz + a1 + a *
log(-a);
51 int jh =
static_cast<int>(ceil(j));
59 int jl =
imax2(1, floor(j)) ;
68 int iterm =
imin2(jd, nterms) ;
69 std::vector<Float> ww(iterm);
70 for (
int k = 0; k < iterm; k++) {
75 for (
int k = 0; k < iterm; k++)
76 sum_ww +=
exp(ww[k] - ww_max);
77 Float ans =
log(sum_ww) + ww_max ;
int imax2(int a, double v)
dvariable lgamma(const prevariable &v)
double fmax2(double a, const dvariable &v)
d3_array exp(const d3_array &arr3)
Returns d3_array results with computed exp from elements in arr3.
double asDouble(const dvariable &v)
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
d3_array pow(const d3_array &m, int e)
Description not yet available.