/* Authors Martin Schlather, martin.schlather@cu.lu library for unconditional simulation of stationary and isotropic random fields Copyright (C) 2002 - 2004 Martin Schlather, This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include "RFsimu.h" void boxcounting(double *z, // data int *lx, // basic length of data int *repet, // "independent" repetitions of data double *factor, // rescalin of data values by factor int *eps, // box lengths int *leps, // length of eps double *sum // leps * repet ) { // in sum, the boxcounting result for the first lx data values is given // according to the box lengths given by eps; then the boxes are counted // for the next lx data values, etc. Hence, sum must have dimension int i, k, lastbox, j, e, r, s, truelx, total; double zz, min, max, f; // boxcounting expects that the first and the last values are repeated // in the first dimension, see D.H.R; accordingly the total length in // the first direction is increased by 2: truelx = 2 + *lx; total = *repet * truelx; s = 0; // 0 to leps * repet -1 for (r=0; r max) max = z[i]; assert(i <= r + *lx + 1); if ((zz = 0.5 * (z[i-1] + z[i])) < min) min = zz; else if (zz > max) max = zz; f = *factor / (double) e; sum[s] += floor(max * f) - floor(min * f) + 1.0; } } } return; } void periodogram(double *dat, // data int *len, // basic length of data int *repet, // # of "independent" repetitions int *fftm, // fftm[0] >=1 not >=1 (R indexing assumed) // interval of the vector given by fft of part int *part, // not the basic length but only a part is // transformed int *shift, // part is then shifted by shift until end of // vector is reached; fft values are averaged // over all these parts double *lambda // (fftm[1] - fftm[0] + 1) * repet ){ int seg_dat, Xerror, k, j, total_seg, segment_r, start_k, end_k, segm_l, lenMpart, delta_l, r, end_l; double factor, *compl_number, n_inv, *taper, taper_fact, cos_factor; FFT_storage FFT; assert(*len >= *part); assert((fftm[0]>=1) && (fftm[1] <=*part) && (fftm[1] >= fftm[0])); assert(*shift>=1); factor = log(2 * PI * *len); lenMpart = *len - *part; start_k = 2 * (fftm[0] - 1); // of complex numbers end_k = 2 * (fftm[1] - 1); // of complex numbers delta_l = fftm[1] - fftm[0] + 1; end_l = delta_l * *repet; n_inv = 1.0 / (double) ((int) (1.0 + (*len - *part) / *shift)); FFT_NULL(&FFT); compl_number = NULL; taper = NULL; if ((compl_number = (double*) malloc(sizeof(double) * 2 * *part))==NULL){ goto ErrorHandling; } if ((taper = (double*) malloc(sizeof(double) * *part))==NULL){ goto ErrorHandling; } for (j=0; j 1); total = *lx * *repet; for (e = r = 0; r < total; r += *lx, e+=*ldfa) { last = r + *lx; for (j=r+1; j 1) { VarMeth_mean = dat[ex - 1] / (realnbox); VarMeth_old = 0; VarMeth_var = 0; for (j=r+m-1; j max) max = dat[idx]; } count[cb] += max - min; } count[cb] = log(count[cb] / (double) epsilon); } // b } // r };