Code covered by the BSD License  

Highlights from
fftnoise - generate noise with a specified power spectrum

Be the first to rate this file! 18 Downloads (last 30 days) File Size: 1.65 KB File ID: #32111
image thumbnail

fftnoise - generate noise with a specified power spectrum

by Aslak Grinsted

 

07 Jul 2011

Useful helper function for Monte Carlo null-hypothesis tests and confidence interval estimation.

| Watch this File

File Information
Description

USAGE: noise=fftnoise(f[,Nseries])
 

INPUTS:
  f: the fft of a time series (must be a column vector)
  Nseries: number of noise series to generate. (default=1)
  
OUTPUT:
  noise: surrogate series with same power spectrum as f. (each column is a surrogate).

  ------ Example: ------
  %calculate if the trend is significantly different from zero
  %(Null-hypothesis: a random process with the same power spectrum as data).
 
  x=(1:100)';
  data=smooth(randn(size(x)),15);
  pdata=polyfit(x,data,1)
  f=fft(data);
  psur=nan(length(pdata),10000);
  for ii=1:size(psur,2)
    psur(:,ii)=polyfit(x,fftnoise(f),1)';
  end
  ptile=prctile(psur(1,:)',[2.5 97.5])
  if (pdata(1)>ptile(2))|(pdata(1)<ptile(1))
    disp('significant trend')
  else
    disp('not significant trend')
  end

MATLAB release MATLAB 6.0 (R12)
Other requirements [ statistics toolbox (prctile.m) is necessary for the listed example ]
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
surrogate Aslak Grinsted 07 Jul 2011 12:07:22
noise Aslak Grinsted 07 Jul 2011 12:07:22
random Aslak Grinsted 07 Jul 2011 12:07:22
generator Aslak Grinsted 07 Jul 2011 12:07:22
statistics Aslak Grinsted 07 Jul 2011 12:07:22
monte carlo Aslak Grinsted 07 Jul 2011 12:07:22
bootstrapping Aslak Grinsted 07 Jul 2011 12:07:22
significance Aslak Grinsted 07 Jul 2011 12:07:22
confidence Aslak Grinsted 07 Jul 2011 12:07:22
stats Aslak Grinsted 07 Jul 2011 12:07:22
pvalue Aslak Grinsted 07 Jul 2011 12:07:22

Contact us at files@mathworks.com