Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define a vector with random steps

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?

like image 563
Joan Avatar asked Mar 22 '18 16:03

Joan


People also ask

What is meant by random vector?

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.

What is a random vector in probability?

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.

Is a random vector a random variable?

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.

What is the difference between random variable and random vector?

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 .


1 Answers

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.

like image 190
Wolfie Avatar answered Oct 01 '22 08:10

Wolfie