0
$\begingroup$

I'm currently building a simulator to model transportation between an origin and a destination. If I have all the historical data since 4 years, how can I generate origin and destination using random numbers ?

Here's my solution(sorry for for my english, I speak french):

  • Get the number of transport for each zone
  • build a cumulative relative frequency distribution
  • Generate pseudorandomly variable with (approximately) uniform distribution
  • return the zone according to the variable

Ex:

[Between ; and[ :Zone
[0,00 ; 0,33[ :13
[0,33 ; 0,53[ :3
[0,53 ; 0,71[ :19
[0,71 ; 1.00[ :11

if U(0,1) = 0.432, then my originZone will be 3

Is it statistically correct ?

Thanks

  • 0
    ? What do you mean by "Get the number of transport for each zone"2017-02-17
  • 0
    The number of transport in which the origin zone is x... The relative frequency for zone x will be x/total number of transport2017-02-17
  • 0
    You could do this with an `if-elseif` structure that assigns uniform values between 0 and .33 to zone 13, values between .33 and .53 to zone 3 and so on. (You should never hit a boundary.) // In R statistical software there is a built-in function for this kind of application that uses uniform random variables in the background: `sample(c(13,3,19,11), n, repl=T, prob=c(.33,.20,.18,.29))`, where `n` is the number of assignments to be made2017-02-17
  • 0
    Thanks ! I appreciate it !2017-02-17

0 Answers 0