How to add random Noise between 2% in the dataset

1 Ansicht (letzte 30 Tage)
Stephen john
Stephen john am 17 Mär. 2022
Kommentiert: Jeff Miller am 18 Mär. 2022
Hello I Hope you are doing well.
I have the following dataset. I Want to add random noise 2% in the data. How can i do that in MATLAB.
I also want to randomly select the noise between 0.5 to 2%.
Can anybody help me in this
  2 Kommentare
Walter Roberson
Walter Roberson am 18 Mär. 2022
Should the random noise be up to 2% of the maximum absolute value? So with the maximum value being 1000, should the noise at every location be up to 20 in absolute value?
Or should the noise at each point be proportional to the value that is stored in that point? So the places that are (say) 3 would be changed to no more than 3.06 ?
Stephen john
Stephen john am 18 Mär. 2022
@Walter Roberson if you share for both methods ,i will be very grateful

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jeff Miller
Jeff Miller am 17 Mär. 2022
Do you mean that you want to multiply each value in the dataset by a random number between 1.005 and 1.02, with all random numbers equally likely in that range? This could be done with something like:
multiplier = 1.005 + rand(size(values))*(1.02-1.005);
values = values *. multiplier;
  5 Kommentare
Walter Roberson
Walter Roberson am 18 Mär. 2022
Suppose you have a value, x, and you want to add to it a value that is between 0% and 2% of x.
Let r denote a random variable in the range [0, 1]. Then between 0% and 2% of x is r * (2/100) * x which is . Now let us add this value to x getting . Both terms involve x, so factor that out, getting which is between and . Which is between and x * 1.02 . Hence if you pick a random number in the range 1 to 1.02 and multiply it by the original value, you will get the same result as if you had specifically decomposed into an addative term and added it to the original value.
When you are adding to a value another value that is linearly proportionate to the original value, then you can express the whole thing as a multiplication by (1 + quantity)
Jeff Miller
Jeff Miller am 18 Mär. 2022
@Stephen john Sorry I am not following you. Maybe you could give a few numerical examples?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by