How to add random Noise between 2% in the dataset

1 回表示 (過去 30 日間)
Stephen john
Stephen john 2022 年 3 月 17 日
コメント済み: Jeff Miller 2022 年 3 月 18 日
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 ?
Stephen john
Stephen john 2022 年 3 月 18 日
@Walter Roberson if you share for both methods ,i will be very grateful

サインインしてコメントする。

回答 (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 Center および File ExchangeCreating 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