# probability data distribution randomly or with some probability

3 views (last 30 days)

Show older comments

##### 0 Comments

### Answers (1)

Torsten
on 15 Nov 2017

Edited: Torsten
on 15 Nov 2017

Let a(j) be the number of vehicles arriving between hour j-1 and hour j (j=1,...,24). So a is a row vector with 24 element.

Then do the following:

b(1)=0;

b(2:25)=cumsum(a(1:24));

b=b/b(25);

r=rand(1,10000);

random=interp1(b,linspace(0,24,25),r);

"random" gives you 10000 arrival times which lie between 0 and 24. If random(i) lies between integers j-1 and j (1<=j<=24)) means that the car arrives between hour j-1 and hour j.

Best wishes

Torsten.

##### 3 Comments

Torsten
on 15 Nov 2017

But the number of EVs between hour j-1 and j (thus a(j)) is the y-value of your graphics from above, isn't it ?

Best wishes

Torsten.

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!