/* calculates rates and LOG(probabilities) */ void inithermitcat (long categs, MYREAL alpha, MYREAL theta1, MYREAL *rate, MYREAL *probcat) { long i; MYREAL *hroot; MYREAL std = SQRT2 * theta1 / sqrt (alpha); hroot = (MYREAL *) mycalloc (categs + 1, sizeof (MYREAL)); root_hermite (categs, hroot); // calculate roots hermite_weight (categs, hroot, probcat); // set weights for (i = 0; i < categs; i++) // set rates { rate[i] = theta1 + std * hroot[i]; probcat[i] = LOG (probcat[i]); } myfree(hroot); }
/* calculates rates and LOG(probabilities) */ void inithermitcat(long categs, double alpha, double theta1, double *rate, double *probcat) { long i; double *hroot; double std = SQRT2 * theta1/sqrt(alpha); hroot = (double *) calloc(categs+1,sizeof(double)); root_hermite(categs, hroot); // calculate roots hermite_weight(categs, hroot, probcat); // set weights for(i=0;i<categs;i++) // set rates { rate[i] = theta1 + std * hroot[i]; probcat[i] = log(probcat[i]); } free(hroot); }