2
$\begingroup$

I am new to stochastic processes (and actually Mathematica too) and there are many things that I still didn't fully understand yet so please forgive me if I say something wrong.

What I am trying to do is fairly simple. I have a sinusoidal signal and I want to add some noise to it, so that I get a "mixed signal" of the form $$ S(t) = \sin(\omega t) + aN(\sigma,t)$$

where N is a Gaussian white noise with variance $\sigma^2$ and $a$ is an amplitude coefficient (noise amplitude).

I had been searching for the proper way to do this with Mathematica, and from what I had found, most people do this by first constructs a list of values of the signal function (in my case, $\sin(\omega t))$ and then separately constructs another list filled with the noise and finally add the two together to get the mixture. But what I really want to build is something behave like a function, instead of just a plain, discrete list of values, so that I can extract the value of my noisy signal at any arbitrary time and do all sort of things like plotting the signal (continuously) and even put it in a differential equation. But I am not so sure about how to do that.

Speaking of stochastic differential equation, I had also tried ItoProcess to solve a differential equation involving Gaussian white noise with arbitrary amplitude and variance (i.e $\frac{dx}{dt} = f(x,t) + aN(\sigma,t)$ ), but I got very confused about how it works (perhaps this is because of my lack of understanding in the actual Ito Process in mathematics). I am expecting to have two parameters to specify the noise I put in my DE, one for the amplitude and the other for the variance, but the actual ItoProcess has only one parameter associated with the noise (the "diffusion"). I had tried to google for an explanation (both the mathematical and mathematica's Ito Process), but I am still not very sure what is it and how do what I intended to do.

Like I said, I have very little knowledge in the mathematics of stochastic processes and there may be something fundamentally wrong with my understanding (I am saying this because I am feeling like I am...and I have no time to learn it all from the beginning), so I decide to ask my question directly instead of just searching around on the web and heading nowhere.

Any input or suggestion will be highly appreciated. Thank you.

$\endgroup$
4
  • $\begingroup$ If you are after a Mathematica solution, posting your already developed code will be helpful. The more effort you show, the higher the chances of getting quality help. At the moment, it seems you need to get up to speed on the mathematical essentials, which this forum would not be the right place for. $\endgroup$
    – Yves Klett
    Commented Oct 10, 2016 at 6:50
  • $\begingroup$ You might need to consider including serial correlation over time if you desire the curve to be smooth at some scale. Assuming independent errors between very small time intervals is not always what one wants. $\endgroup$
    – JimB
    Commented Oct 10, 2016 at 14:37
  • 1
    $\begingroup$ What you want is impossible. Gaussian white noise has infinite amplitude without a bandwidth limit. Sampled noise implicitly has the Nyquist bandwidth. $\endgroup$
    – John Doty
    Commented Oct 22, 2017 at 14:54
  • $\begingroup$ Yeah, after all the time since I asked this question, I realized noises don't work like the way I thought them to be mathematically $\endgroup$
    – AstroK
    Commented Oct 22, 2017 at 14:59

1 Answer 1

7
$\begingroup$

For white noise, you can use WhiteNoiseProcess. This is just a process, so you need to pass it to RandomFunction to get actual white noise data from t=0 to t=tmax. So...

RandomFunction[WhiteNoiseProcess[σ], {0, tmax}]

However, this only returns a discrete set of values. To make it continuous, you need to pass it to Interpolation. A snag is that RandomFunction returns TemporalData, whereas Interpolation requires a conventional list of values. To convert the TemporalData to a normal table of values, you use Normal, so...

Normal[RandomFunction[WhiteNoiseProcess[σ], {0, tmax}]]

A further snag is that the table you want is nested one layer down. To extract it, write...

Normal[RandomFunction[WhiteNoiseProcess[σ], {0, tmax}]][[1]]

This gives you a table of time-value pairs, which you can now pass to Interpolation, like so...

Interpolation[Normal[RandomFunction[WhiteNoiseProcess[σ], {0, tmax}]][[1]]]

You now have your continuous noise function N[σ,t], which is defined between 0 and tmax.

You can plot this like so...

tmax = 10;
ω = 6;
σ = 1;
noise = Interpolation[Normal[RandomFunction[WhiteNoiseProcess[σ],{0, tmax}]][[1]]];
Plot[Sin[ω t] + noise[t], {t, 0, tmax}]

Sine wave with additive white noise

In the above, the RandomFunction only samples the white noise every second. You should be able to sample it more frequently by including a dt, i.e. according to the documentation, RandomFunction[proc,{tmin,tmax,dt}], but this doesn't seem to work for WhiteNoiseProcess.

A workaround, is to scale the time in the RandomFunction and in the Interpolation by the sample rate, as follows...

tmax = 10;
samplesPerSec = 10;
ω = 6;
σ = 1;
noise = Interpolation[Normal[RandomFunction[WhiteNoiseProcess[σ], {0, tmax*samplesPerSec}]][[1]]];
Plot[Sin[ω t] + noise[t*samplesPerSec], {t, 0, tmax}]

Sine wave with additive white noise, more frequently sampled

$\endgroup$
1
  • $\begingroup$ Thanks for your answer $\endgroup$
    – AstroK
    Commented Oct 22, 2017 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.