#include #include /* Implement kernel density-estimation step for location-scale mixture model (17) in Benaglia et al (2008) where each component and block has the same shape but may differ from others by a location and scale, implementing equation (18) */ void KDElocscale( int *nn, /* Sample size */ int *mm, /* Number of components */ int *rr, /* Number of coordinates */ int *blockid, /* r-vector of block numbers */ double *mu, /* m by max(blockid) matrix of current mean estimates */ double *sigma, /* m by max(blockid) matrix of current stdev estimates */ double *x, /* n by r data matrix */ double *hh, /* scalar bandwidth */ double *z, /* n by m vector of normalized posteriors (or indicators in stochastic case), normalized by "column" */ double *f /* n by m matrix of KDE products */ ) { int n=*nn, m=*mm, r=*rr; int i, j, k, ii, kk, ell, ell2; double sum1, sum2, tmp, h=*hh, u; double const1 = -0.5 / (h * h); double const2; for(j=0; j