[time-nuts] Generation of pulse train with 1/4 noise

Jim Lux jimlux at earthlink.net
Fri Feb 15 07:43:19 EST 2013


I need to generate a sequence of pulses at around 1 Hz with a 1/f 
characteristic  (human heartbeat, as it happens). I'd like to do this 
using software and a timer, so I'm looking for a clever algorithm using 
a random number generator to do it.

  I could take the phase noise spectrum and turn that into some form of 
cumulative probability distribution for the period, then generate a 
random number from 0-1 and use the inverse of the CPD to determine the 
period.

But I was wondering if there's some clever way that just happens to 
generate what I'm looking for.  Sort of like how you sum up 12 random 
numbers to generate a Gaussian with variance 1.  and then, the 
Box-Muller algorithm as an alternate way.

A generalized approach for the exponent between 0.5 and 1.5 would be 
useful.

I found some techniques such as building a filter with the required 
power spectral density and then running white noise through it.  There's 
a matlab (& C) package out there called cnoise, as well. cnoise builds 
an array of samples and uses a FFT to do the filtering efficiently.

I'd rather have some sort of difference/recursion equation that I can 
just call each time I need the next interval. I did find some code based 
on a paper by Higham that does what's called the Ornstein-Uhlenbeck 
stochastic difference equation.
	dt = tmax / n;
	x(1) = x0;
	for j=1:n
		dw = sqrt ( dt ) * randn;
		x(j+1) = x(j) + dt*theta*(mu-x(j)) + sigma * dw

But I don't trust it, because the matlab and c versions do not agree.


1/f^2 (brownian) is easy by taking the random number sequence and 
integrating.

x(j+1) = x(j) + randn(1);


More information about the time-nuts mailing list