How does one do simulations for statistics?

Stanley Klein sklein at BERKELEY.EDU
Tue Nov 24 12:43:39 CET 2009

Hi again,
I have had a suggestion to try the freqsimulation function of
Fieldtrip. But I would like to have something in the time domain so
that I can play with autoregressive coefficients between sources and
so that I can put in nonlinearities like multiplicative noise if I'd
like. .

Incidentally the AR coefficients that I had given corresponded to a
filter that looks like:
    t=0:2:199;  %t is in msec
    x=exp(-t/25).*sin(2*pi*t/60);    %this gives about one damped
cycle with 60 msec period
    XX=[x(3:100); x(2:99); x(1:98)];
    coef=XX(1,:)/XX(2:3,:)    %linear regression to get AR coefficients

where coef = [1.806 -.852] from this linear regression, which is
similar to what I had sent in my previous email for generating the
noisy filtered time series.

Again, my question is how to generate noise that looks like EEG or
MEG. Can I do an adequate job simply by getting nice AR coefficients
(what would some good coefficients be?)  or do I need to do fancier
things? For example, should I worry about sparse bursts of alpha? What
do people commonly do to simulate data. I like to use simulated time
in addition to real data so that I am confident about what is going on

On Tue, Nov 24, 2009 at 2:18 AM, Stanley Klein <sklein at> wrote:
> I too have lots of questions on how to do statistics on EEG and MEG.
> Right now for example we are getting very similar EEG and MEG
> waveforms (following SVD) and are trying out various statistical ways
> of comparing them. In addition to using Fieldtrip's wonderful (but
> complicated) cluster permutation test for dealing with multiple
> comparisons and correlated noise issues we are trying other ideas. The
> only way that we can figure out whether we are on the right track is
> to do simulations where we know the correct answer. Does anyone have
> good advice on how to do good simulations? We are using the CTF
> machine for our EEG and MEG (and Biosemi for EEG alone). Every sample
> is about 2 msec. For a single trace  we are using something like the
> following Matlab code that gives a flat amplitude spectrum out to 15
> Hz and then close to 1/f^2 beyond that.
> x(1:2)=[0 1];
> for i=3:10000;
>   x(i) = 1.81*x(i-1) -.85*x(i-2)+randn;  %AR model for time series
> end
> The AR coefficients were obtained by trial and error and have a lot of
> flexibility.
> The question again is whether anyone has good suggestions for how to
> simulate EEG or MEG noise in the time domain?  Even better would be
> something good to read.   I'd like the noise to be manufactured in the
> time domain since I'll be doing other things for the signal in the
> time domain including multiplicative noise. Without good simulations
> how do people test all their statistics, especially when there is a
> bunch of preprocessing like SVD (or complicated, nonlinear interaction
> terms)?
> thanks,
> Stan Klein

The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also and

More information about the fieldtrip mailing list