Adding noise to data

Dear users,

I would like to add noise to data in my code using FF++,
Can anyone send please an example of adding noise?

Thanks in advance,
Mordechai.

Depends what kind of noise. If you want simple white noise,

Vh toto = sin(x)*(1+0.2*randreal1());
plot(toto,wait=1,value=1,fill=1);

should do the job

Thank you Julien!

I would like to add a Gaussian noise to my data in the following way:
suppose u(x,t) is my data with no noise,
define
u_with_noise=(1+coeff*randn)*u(x,t).
Where, “coeff” is the level of noise and “randn” is a centered normal law.

I found a code for randn which uses the Box-Muller transform

func real randn()
{
real U1, U2;
U1 = randreal3();
U2 = randreal3();
return sqrt(-2log(U1))cos(2piU2);
}

I defined in my code that
real coeff=0.2; (20% level of noise)
u is calculated in the code and I used the piece of code that generates “randn”
thus,
u_with_noise=(1+coeff*randn)*u(x,t);

Is it correct?

Thanks in advance,
Mordechai.