How to add random Noise between 2% in the dataset

1 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2022-3-18
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 ?

请先登录,再进行评论。

回答(1 个)

Jeff Miller
Jeff Miller 2022-3-17
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 个评论
Walter Roberson
Walter Roberson 2022-3-18
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 2022-3-18
@Stephen john Sorry I am not following you. Maybe you could give a few numerical examples?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by