1 /* rTrait.c 2011-06-25 */
3 /* Copyright 2010-2011 Emmanuel Paradis */
5 /* This file is part of the R-package `ape'. */
6 /* See the file ../COPYING for licensing issues. */
10 void rTraitCont(int *model, int *Nedge, int *edge1, int *edge2, double *el,
11 double *sigma, double *alpha, double *theta, double *x)
13 /* The tree must be in pruningwise order */
18 case 1 : for (i = *Nedge - 1; i >= 0; i--) {
20 x[edge2[i]] = x[edge1[i]] + sqrt(el[i]) * sigma[i] * norm_rand();
24 case 2 : for (i = *Nedge - 1; i >= 0; i--) {
26 alphaT = alpha[i] * el[i];
28 S = sigma[i] * sqrt((1 - exp(-2 * alphaT))/(2 * alpha[i]));
29 } else { /* same than if (alpha[i] ==0) */
31 S = sqrt(el[i]) * sigma[i];
34 x[edge2[i]] = x[edge1[i]] * M + theta[i] * (1 - M) + S * norm_rand();