#include #include #include #include #include #define true 1 #define false 0 #ifndef iabs #define iabs(x) ((x) >= 0 ? (x) : -(x)) #endif #ifndef MIN #define MIN(x,y) ((x)<(y)?(x):(y)) #endif #ifndef MAX #define MAX(x,y) ((x)>(y)?(x):(y)) #endif int bin1 (float *, int, float *, int, int *); int ash1 (int, int *, int, float *, float *, float *, float *, float *); /************************************************************************/ int do_ash1d(float *vals, int nvals, int nbins, int n_ashes, float *ashed_vals, float *lims_min, float *lims_max) { int i, k, icheck; int *bins; float min, max, ab[2]; /* for computing nicerange -- extending the range */ float del, beta = 0.2; /* for ash1 */ int ash_return; float *f, *t, *w; /* w = weights */ float kopt[] = {2.0, 2.0}; /* S function default values for kernel options */ float binwidth; /* for generating the interpolated values to plot */ float ti; bins = (int *) malloc(nbins * sizeof(int)); min = max = vals[0]; for (i=1; i= 1 && k <= nbin) nc[k] += 1 ; else nskip += 1; } return nskip; } /* c April 8, 1986 c c Computer ASH density estimate; Quartic (biweight) kernel c Average of "m" shifted histograms c c Bin counts in array "nc(nbin)" - from routine "bin1" c "nbin" bins are formed over the interval [a,b) c c ASH estimates returned in array "f(nbin)" c c FP-ASH plotted at a+d/2 ... b-d/2 where d = (b-a)/nbin c c Note: If "nskip" was nonzero, ASH estimates incorrect near boundary c Note: Should leave "m" empty bins on each end of array "nc" so f OK c ##### Copyright 1986 David W. Scott */ int ash1 ( int m, int *nc, int nbin, float *ab, float *kopt, float *t, float *f, float *w ) { /* nc(nbin), ab(2), t(nbin), f(nbin), w(m), kopt(2) */ float a, b, delta, cons, c, h; int i, k, n; int ier = 0 ; a = ab[0] ; b = ab[1] ; n = 0 ; /* * compute weights cons * ( 1-abs((i/m))^kopt1)^kopt2 * -- should sum to "m" 5-8-91 * w-array shifted by 1 */ /* * cons = sum of weights from -(m-1) to (m-1) = 1 + 2 (sum from 1 to m-1) */ w[0] = 1.0 ; cons = 1.0 ; for (i=1; i 0) { ier = 1 ; } } /* * compute ash(m) estimate */ delta = (b-a) / (float) nbin ; h = (float) m * delta ; for (i=0; i