Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Add Noise to Data

Subject: Add Noise to Data

From: NN

Date: 20 Jun, 2014 14:36:13

Message: 1 of 7

Hi All,
Could anyone here help me with some information on how to add a Gaussian Noise to a set of data generated randomly? Here is what I did:
Let ydata be the data generate, I add the 10% Gaussian noise to get
ydataNew = ydata + 0.1+rand(length(ydata),1).
Is there any difference between the above expression with the following:
ydataNew = ydata (1+ 0.1+rand(length(ydata),1))?

Besides, I also wanted to know if anyone has some tips on how to set the Levenberg-Marquardt parameter, in case he/she decides to implement his/her own LM code for neural network training?
I already tried using the inbuilt LM algorithm but need some adaptation which can be achieved easily ny simply coding the algorith,
I look forward to your reply.
Thanking!

Subject: Add Noise to Data

From: Greg Heath

Date: 21 Jun, 2014 05:42:06

Message: 2 of 7

"NN " <g.cool77@yahoo.com> wrote in message <lo1gst$bj4$1@newscl01ah.mathworks.com>...
> Hi All,
> Could anyone here help me with some information on how to add a Gaussian Noise to a set of data generated randomly? Here is what I did:
> Let ydata be the data generate, I add the 10% Gaussian noise to get
> ydataNew = ydata + 0.1+rand(length(ydata),1).
> Is there any difference between the above expression with the following:
> ydataNew = ydata (1+ 0.1+rand(length(ydata),1))?

For a theoretical signal-to-noise ratio of SNR0 = 100

close all, clear all, clc
  t = linspace( 0, 2*pi, 128 );
 x0 = cos(t);
 varx0 = var(x0) % 0.5078 (0.5 theory)
 SNR0 = 100
 rng(0)
 n = randn(1,128);
 varn = var(n) % 1.3379 (1.0 theory)
 x = x0 + sqrt(varx0/SNR0)*n;
 varxest = var(x0)+varx0/SNR0 % 0.5129 estimate
 varx = var(x) % 0.5281 result
 PctErr = 100*(varx-varxest)/varx % 2.8859

Hope this helps,

Greg

Subject: Add Noise to Data

From: Bruno Luong

Date: 21 Jun, 2014 08:17:18

Message: 3 of 7

"NN " <g.cool77@yahoo.com> wrote in message <lo1gst$bj4$1@newscl01ah.mathworks.com>...
> Hi All,
> Could anyone here help me with some information on how to add a Gaussian Noise to a set of data generated randomly? Here is what I did:
> Let ydata be the data generate, I add the 10% Gaussian noise to get
> ydataNew = ydata + 0.1+rand(length(ydata),1).
> Is there any difference between the above expression with the following:
> ydataNew = ydata (1+ 0.1+rand(length(ydata),1))?

Just FYI, rand() generates uniform noise, _not_ Gaussian noise
>
> Besides, I also wanted to know if anyone has some tips on how to set the Levenberg-Marquardt parameter, in case he/she decides to implement his/her own LM code for neural network training?
> I already tried using the inbuilt LM algorithm but need some adaptation which can be achieved easily ny simply coding the algorith,
> I look forward to your reply.

Just search at the archive of the Newsgroup, I believe I have posted once or twice some hand coded LM algorithm.

Bruno

Subject: Add Noise to Data

From: NN

Date: 22 Jun, 2014 19:44:10

Message: 4 of 7

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <lo3f2e$cae$1@newscl01ah.mathworks.com>...
> "NN " <g.cool77@yahoo.com> wrote in message <lo1gst$bj4$1@newscl01ah.mathworks.com>...
> > Hi All,
> > Could anyone here help me with some information on how to add a Gaussian Noise to a set of data generated randomly? Here is what I did:
> > Let ydata be the data generate, I add the 10% Gaussian noise to get
> > ydataNew = ydata + 0.1+rand(length(ydata),1).
> > Is there any difference between the above expression with the following:
> > ydataNew = ydata (1+ 0.1+rand(length(ydata),1))?
>
> Just FYI, rand() generates uniform noise, _not_ Gaussian noise
> >
> > Besides, I also wanted to know if anyone has some tips on how to set the Levenberg-Marquardt parameter, in case he/she decides to implement his/her own LM code for neural network training?
> > I already tried using the inbuilt LM algorithm but need some adaptation which can be achieved easily ny simply coding the algorith,
> > I look forward to your reply.
>
> Just search at the archive of the Newsgroup, I believe I have posted once or twice some hand coded LM algorithm.our
>
> Bruno

Hi Bruno,ied searching for the LevenbergMarquartd you hard coded but couldnt find anything. I can send you the simplified version of my data fitting LM to compare with yours. Please could you send me yours to cross check instead? I am really stuck on how to proceed, since it doesnt give me the desired solution for adaptation in the special neural network training.
Thanking!
Thanks alot for the reply. I tr

Subject: Add Noise to Data

From: NN

Date: 22 Jun, 2014 20:24:07

Message: 5 of 7

"Greg Heath" <heath@alumni.brown.edu> wrote in message <lo35ve$mm3$1@newscl01ah.mathworks.com>...
> "NN " <g.cool77@yahoo.com> wrote in message <lo1gst$bj4$1@newscl01ah.mathworks.com>...
> > Hi All,
> > Could anyone here help me with some information on how to add a Gaussian Noise to a set of data generated randomly? Here is what I did:
> > Let ydata be the data generate, I add the 10% Gaussian noise to get
> > ydataNew = ydata + 0.1+rand(length(ydata),1).
> > Is there any difference between the above expression with the following:
> > ydataNew = ydata (1+ 0.1+rand(length(ydata),1))?
>
> For a theoretical signal-to-noise ratio of SNR0 = 100
>
> close all, clear all, clc
> t = linspace( 0, 2*pi, 128 );
> x0 = cos(t);
> varx0 = var(x0) % 0.5078 (0.5 theory)
> SNR0 = 100
> rng(0)
> n = randn(1,128);
> varn = var(n) % 1.3379 (1.0 theory)
> x = x0 + sqrt(varx0/SNR0)*n;
> varxest = var(x0)+varx0/SNR0 % 0.5129 estimate
> varx = var(x) % 0.5281 result
> PctErr = 100*(varx-varxest)/varx % 2.8859
>
> Hope this helps,
>
> Greg

Hi Greg,
Thanks alot. I am not sure if I really have to find the signal to noise ratio. Anyways, I generated the artificial data using a neural network model, and wish to check if it possible to train and identify the model using some novel methods. I will also take a look at your idea and consider it in case it helps me clear this problem of how to add the required noise to the data.
Thanks alot.

Subject: Add Noise to Data

From: Bruno Luong

Date: 22 Jun, 2014 20:50:15

Message: 6 of 7

Here is a thread where you can find an implementation of Levenberg Marquardt and take some ideas from:

http://www.mathworks.com/matlabcentral/newsreader/view_thread/281583

Bruno

Subject: Add Noise to Data

From: Greg Heath

Date: 22 Jun, 2014 21:59:13

Message: 7 of 7

"NN " <g.cool77@yahoo.com> wrote in message <lo7e17$g1v$1@newscl01ah.mathworks.com>...
> "Greg Heath" <heath@alumni.brown.edu> wrote in message <lo35ve$mm3$1@newscl01ah.mathworks.com>...
> > "NN " <g.cool77@yahoo.com> wrote in message <lo1gst$bj4$1@newscl01ah.mathworks.com>...
> > > Hi All,
> > > Could anyone here help me with some information on how to add a Gaussian Noise to a set of data generated randomly? Here is what I did:
> > > Let ydata be the data generate, I add the 10% Gaussian noise to get
> > > ydataNew = ydata + 0.1+rand(length(ydata),1).
> > > Is there any difference between the above expression with the following:
> > > ydataNew = ydata (1+ 0.1+rand(length(ydata),1))?
> >
> > For a theoretical signal-to-noise ratio of SNR0 = 100
> >
> > close all, clear all, clc
> > t = linspace( 0, 2*pi, 128 );
> > x0 = cos(t);
> > varx0 = var(x0) % 0.5078 (0.5 theory)
> > SNR0 = 100
> > rng(0)
> > n = randn(1,128);
> > varn = var(n) % 1.3379 (1.0 theory)
> > x = x0 + sqrt(varx0/SNR0)*n;
> > varxest = var(x0)+varx0/SNR0 % 0.5129 estimate
> > varx = var(x) % 0.5281 result
> > PctErr = 100*(varx-varxest)/varx % 2.8859
> >
> > Hope this helps,
> >
> > Greg
>
> Hi Greg,
> Thanks alot. I am not sure if I really have to find the signal to noise ratio. Anyways, I generated the artificial data using a neural network model, and wish to check if it possible to train and identify the model using some novel methods. I will also take a look at your idea and consider it in case it helps me clear this problem of how to add the required noise to the data.
> Thanks alot.

I have designed hundreds of robust nets starting with noise free data.

The naïve approach is to

1. Design using noise-free data
2. Test with noisy data.
3. Quantify performance as a function of SNR

A better method is to just modify the first step

1a. Design using noise added data

Considering that no matter what you do, performance degrades inversely with SNR, you will have to experiment. The best way I have found to do this is

Plot performance vs design SNR (SNRd) with test SNR (SNRt) as a parameter.

Hope this helps.

Greg

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us