next up previous contents
Next: Function: monte_carlo() Up: GRASP Routines: Stochastic background Previous: Function: simulate_sb()   Contents


Function: combine_data()

0

void combine_data(int which, int n, float *in1, float *in2, float *out)
This low-level function takes two arrays as input, shifts them by half their length, and combines them with one another and with data stored in an internally-defined static buffer to produce output data that is continuous from one call of combine_data() to the next.

The arguments of combine_data() are:

which: Input. An integer variable specifying which internally-defined static buffer should be used when combining the input arrays with data saved from a previous call. The allowed values are $1\le{\tt which}\le 16$.
n: Input. The number $N$ of data points contained in the input and output arrays. $N$ is assumed to be even.
in1: Input. in1[0..n-1] is an array of floating point variables containing the values of the first input array.
in2: Input. in2[0..n-1] is an array of floating point variables containing the values of the second input array.
out: Output. out[0..n-1] is an array of floating point variables containing the output data, which is continuous from one call of combine_data() to the next.

combine_data() produces continuous output data by modifying the appropriately chosen static buffer buf[0..3*n/2-1] as follows:

    $\displaystyle {\tt buf[i]+=sin[i*M\_PI/n]*in1[i]}\quad{\rm for}\quad
{\tt0}\le{\tt i}\le{\tt n/2-1}$  
    $\displaystyle {\tt buf[i]+=sin[i*M\_PI/n]*in1[i]+sin[(i-n/2)*M\_PI/n]*in2[i-n/2]}
\quad{\rm for}\quad{\tt n/2}\le{\tt i}\le{\tt n-1}$  
    $\displaystyle {\tt buf[i]+=sin[(i-n/2)*M\_PI/n]*in2[i-n/2]}\quad{\rm for}\quad
{\tt n}\le{\tt i}\le{\tt 3*n/2-1}\ .$  

The values of the output array out[0..n-1] are taken from the first two-thirds of the buffer, while the last one-third of the buffer is copied to the first third of the buffer in preparation for the next call. When this is complete, the last two-thirds of the buffer is cleared.

One nice feature of combining the data with a sine function (rather than with a triangle function, for example) is that if the input data represent statistically independent, stationary random processes having zero mean and the same variance, then the output data will also have zero mean and the same variance. This is a consequence of the trigonometric identity

\begin{displaymath}
{\tt sin}^2{\tt [i*M\_PI/n]+sin}^2{\tt [(i-n/2)*M\_PI/n]=1}\ .
\end{displaymath} (11.11.239)

Thus, combine_data() preserves the first and second-order statistical properties of the input data when constructing the output.

Authors: Bruce Allen, ballen@dirac.phys.uwm.edu, and Joseph Romano, romano@csd.uwm.edu
Comments: In the context of stochastic background simulations, the two input arrays would represent two whitened data streams produced by a single detector, which are then time-shifted and combined to simulate continuous-in-time detector output. Since the contents of the internally-defined static buffer are equal to zero when combine_data() is first called, the amplitude of the output array initially builds up from zero to its nominal value over the course of the first $N/2$ data points. This corresponds to an effective ``turn-on'' transient, with turn-on time equal to $N\ \Delta t/2$ ($\Delta t$ being the time between successive data samples).


next up previous contents
Next: Function: monte_carlo() Up: GRASP Routines: Stochastic background Previous: Function: simulate_sb()   Contents
Bruce Allen 2000-11-19