I would like to create an N
by 1
array of doubles where N
is any integer value. Each value in the array should deviate from a nominal value n
using a standard deviation of n/10
and mean of 0
. n
can be any integer or double value.
Is there a way to do this in MATLAB using randn()
with the mean and standard deviation as input parameters?
I think that this should solve your problem:
N = 10;
n = 5;
standard_deviation = n / 10;
% Generates a vector of N ones, then moltiply it to the scalar n
nominal_values = n * ones(N, 1);
% Generates a vector of N standard random normal realizations, then multiply them to the scalar (n/10) -> you get a centered random normal with std n/10
deviations = standard_deviation * randn(N, 1);
% Get the final result
result_array = nominal_values + deviations;
I hope this will solve your problem, you are welcome to ask for a clarification if needed.