Reputation: 75
I have a number
27.50.
I want to spread it in an array Result
, size of which is 2000.
The distribution of 27.50 in array Result
shall start from 1 and end at 27.50.
number = 27.50;
Size = 2000;
Result = zeros(Size ,1);
I want it to distribute it in a such way that when I do cumsum
of Result
, final index shall have 27.50 and when I do sum
of Result
it shall be equal to 27.50.
Expected Result:
tmp = cumsum(Result)
tmp(end) == 27.50
sum(Result) == 27.50
Question:
Is there any possible way to do it? If yes please advice what method shall I use*
Upvotes: 0
Views: 80
Reputation: 2351
I guess you can do it in many ways.
As @rahnema1 mentioned you can use a uniform distribution:
repmat(number/Size ,Size ,1)
Or you can use also a Gaussian:
normcdf(0:Size,1000,100) %choose the parameters yo want
Or any other distribution you want.
The key point is that you must normalize your distribution in a way that the sum under it is equal to the value you want: 27.50
in your case.
Upvotes: 2