The Mathematica documentation center provides an example of how to add noise to a process: White Noise Process.

\[ScriptCapitalP] = TransformedProcess[
             Cos[t/8] + noise[t], 
             noise \[Distributed] WhiteNoiseProcess[UniformDistribution[{-1/5, 1/5}]],

data = RandomFunction[\[ScriptCapitalP], {0, 200}];
ListPlot[data, Filling -> Axis]

Mathematica graphics

I'm also able to do the same with Gaussian noise, in which case I use NormalDistribution[0, 1] instead of UniformDistribution[{-1/5, 1/5}].

I have now two problems:

  • The first one is that I want the standard derivation to be a function of time, so NormalDistribution[0, f[t]], but this doesn't work.
  • The second problem is that I always get nothing when I choose the variance to be zero, which should effectively correspond to no noise.

Can someone help?

  • $\begingroup$ When I have no noise, so zero mean and zero variance, I should get the original process back again, which I don't. Was only curious about that. $\endgroup$ – QuantumMechanics Nov 23 '15 at 12:41
  • $\begingroup$ Now I see, sorry I wasn't paying close enough attention $\endgroup$ – sebhofer Nov 23 '15 at 15:33
  • $\begingroup$ Mathematica can't handle the (singular) case of $\sigma\rightarrow 0$. Try PDF[NormalDistribution[0, 0], x], which throws the error NormalDistribution::posprm: "Parameter 0 at position 2 in NormalDistribution[0,0] is expected to be positive.". $\endgroup$ – sebhofer Nov 23 '15 at 17:40

The nice thing about NormalDistribution is that it scales:

In[104]:= TransformedDistribution[sigma*u, 
 u \[Distributed] NormalDistribution[0, 1]]

Out[104]= NormalDistribution[0, Abs[sigma]]

So NormalDistribution[0, f[t]] is equivalent to f[t]*NormalDistribution[0,1], assuming f[t] is positive.

Then just adjust the transformation in TransformedProcess:

proc = 
  TransformedProcess[Cos[t/8] + Sqrt[t]*noise[t], 
  noise \[Distributed] WhiteNoiseProcess[NormalDistribution[0, 1]],t];
data = RandomFunction[proc, {0, 200}];
ListPlot[data, Filling -> Axis]

with the adjusted noise

| improve this answer | |
  • $\begingroup$ Thanks for your answer. How can I increase the number of points? When I'm using RandomFunction[proc,{0,200,0.2}] I always get an error... $\endgroup$ – QuantumMechanics Nov 23 '15 at 11:14
  • $\begingroup$ That is bc WhiteNoiseProcess in M is a discrete time process and RandomFunction can only output sample on integers. What you can do is to specify the length of the sample and then use TimeSeriesRescale to rescale time stamps to the MinimumTimeIncrement of your choice. $\endgroup$ – Gosia Nov 23 '15 at 21:51

I don't have any experience with TransformedProcess or RandomFunction, but coulddn't you just make your own noise and add it to the data?

data = Cos[#/8] + 
     RandomVariate[NormalDistribution[0, # .001 + .05]] & /@ 
   Range[0, 200];
ListPlot[data, Filling -> Axis]

enter image description here

| improve this answer | |
  • $\begingroup$ Thanks for your answer, I will try to implement this later! :-) $\endgroup$ – QuantumMechanics Nov 20 '15 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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