I want to create an array that has incremental random steps, I've used this simple code.
t_inici=(0:10*rand:100);
The problem is that the random number keeps unchangable between steps. Is there any simple way to change the seed of the random number within each step?
A random vector is a vector whose value depends on the outcome of the experiment, as stated by the following definition. Definition Let be a sample space. A random vector is a function from the sample space to the set of -dimensional real vectors : In rigorous probability theory, the function.
In probability, and statistics, a multivariate random variable or random vector is a list of mathematical variables each of whose value is unknown, either because the value has not yet occurred or because there is imperfect knowledge of its value.
A vector random variable X = (X1,X2,...,Xn) is a collection of random numbers with probabilities assigned to outcomes. X can also be called a multivariate random variable. The case with n = 2 we call a bivariate random variable.
4.8 General concept of a random variable A random variable X:S↦R X : S ↦ R is a measurable mapping from the sample space S into the set of real numbers R , while a d -dimensional random vector is a measurable mapping from S into the d -dimensional Euclidean space Rd .
If you have a set number of points, say nPts
, then you could do the following
nPts = 10; % Could use 'randi' here for random number of points
lims = [0, 10] % Start and end points
x = rand(1, nPts); % Create random numbers
% Sort and scale x to fit your limits and be ordered
x = diff(lims) * ( sort(x) - min(x) ) / diff(minmax(x)) + lims(1)
This approach always includes your end point, which a 0:dx:10
approach would not necessarily.
If you had some maximum number of points, say nPtsMax
, then you could do the following
nPtsMax = 1000; % Max number of points
lims = [0,10]; % Start and end points
% Could do 10* or any other multiplier as in your example in front of 'rand'
x = lims(1) + [0 cumsum(rand(1, nPtsMax))];
x(x > lims(2)) = []; % remove values above maximum limit
This approach may be slower, but is still fairly quick and better represents the behaviour in your question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With