random number from a data set with a specified error

2 views (last 30 days)
Hi All, I am trying to generate a set of random numbers from a given distribution. The randn option gives a set of values with a definite mean and standard deviation. However, my intention is to generate several sets of random numbers from a known set of data within a specified error. Please suggest. Atanu

Accepted Answer

Geoff
Geoff on 14 Mar 2012
This question is open to interpretation.
What I think you have is a dataset X with known standard deviations S (a vector containing one deviation for each value in X), and you want to generate a whole bunch of pseudo-X datasets that are randomised the known distributions of X.
If that's the case, you can generate a single set as follows:
N = length(X);
pX = X + S .* randn(1,N);
Repeat as many times as you like.
The error will be normally distributed around each point in X by the known standard deviation at that point.
If you have an error rather than standard deviation, and want random noise within that range, you might do it with a linear distribution instead of normal (let's assume E is an absolute error value, so we're varying within X +/- E):
pX = X + (rand(1,N)*2-1) .* E;
-g-
  3 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Random Number Generation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!