Portal-generated trains: are they really random?

Pendolino

Cab mode weirdo
Hello folks,

I am beginning to have some doubt about the actual randomness of train generation from portals. I noticed some portal-generated trains appear much often than others that are very rarely seen, so I took some notes while testing a session.

The session uses 4 portals (actually, trackmarks configured as portals using the "Un-portal" rule) to generate random freight trains. Portal 1 has a 6-consist list, Portal 2 has a 7-consist list, Portals 3 & 4 have a 4-consist list.

NOTE: A friend of mine has noticed the same behaviour - even though he has not recorded it - when using the "Un-portal 2" rule. We do not know it this issue also applies to other portal types (e.g. the standard Auran built-in portals), but we think - maybe wrongly - the random selection process used is the same.

These are the data I collected after 40 tests:

Portal #1GeneratedActual %Expected %Actual/Expected
Train #11537,5%16,7%225%
Train #237,5%16,7%45%
Train #3512,5%16,7%75%
Train #4410,0%16,7%60%
Train #5410,0%16,7%60%
Train #6922,5%16,7%135%
40
Portal #2
Train #11128%14,3%193%
Train #238%14,3%53%
Train #3513%14,3%88%
Train #425%14,3%35%
Train #5615%14,3%105%
Train #6513%14,3%88%
Train #7820%14,3%140%
40
Portal #3
Train #11845%25,0%180%
Train #2513%25,0%50%
Train #3615%25,0%60%
Train #41128%25,0%110%
40
Portal #4
Train #11948%25,0%190%
Train #2410%25,0%40%
Train #3718%25,0%70%
Train #41025%25,0%100%
40

As you can see, in all portals Train #1 is generated much often than expected: 180% to 225%; the same could also be true - to a lesser extent - for the last train (100% to 140%).

Is this effect inevitable - and associated with the way computers generate random variables - or there are ways to obtain uniformly distributed random results?

Thanks in advance.
 
A large majority of contents creators relies on a standard random function in their script Math.Rand(int lowValue, int UpperValue) which should return a number between the low value and the upper value with uniformly distributed results. And I don't think many creators have checked if the results are effectively uniformly distributed or not. And as this standard random function is generally derived from a similar function available in the system library of the computer used, we are generally totally dependent of the computer manufacturer implementation ...

There are a lot of other methods to write from scratch some random number generator, but that is a lot of work to implement and also a lot of script time consumed for that and I don't think many creators are ready to reinvent the wheel only to have better uniform random distribution ...

But that's only my opinion.
Regards.
Pierre.
 
Hi

I too have noticed that the random distribution using Un-Portal 2 doesn't appear to be particularly random although I haven't kept records. Looking at your results above it strikes me that this could be used to advantage in some situations. As you have pointed out that the first and last entries produce most consists then, on a predominately coal route such as EK3 for example, it would make sense to use the first and last slots for coal trains and the other slots for consists that would appear less frequently.

I use Un-Portal 2 to generate random AI background traffic on a route in a coal producing area so I will reload the portals in accordance with your findings and see what happens.

Regards

Brian
 
Thanks for the replies.

@pguy:

I'm almost illitterate as regards to scripting: do you mean that the distribution of random-generated values may change depending on the PC on which the script is run?

@Kennilworth:

As the saying goes, "When life gives you lemons, make lemonade" :D. I agree with your idea of using slot #1 for the most common train running on a given line.

Iam still collecting data for the purpose of formulating some empirical "law", so as to be able to reasonably predict which trains will be spawned. So far, I'm reasonably certain that, for a portal spawning X trains, the probability of having Train #1 spawned is 2 times 1/X.

In my example, Portals #1 and #2 are located near a port and an intermodal terminal: I set both of them so that Train #1 is a ballast train and the remainder are container trains, with a few grain hopper trains. I thought I will mostly see colourful freights, but what I got is an endless parade of ballast trains :(.

Regards
 
Very interesting little study there, Carlo. I wonder too if the randomness isn't quite as random as it should be because the numbered range is so small. If we had a pool of hundreds of consists, then I would think the values maybe a bit more widespread.

I do like Brian's use of coal consists. I can see that being very helpful on the EKV which I have integrated into a much larger and more complex operation where empties are a bit of a problem. :)

John
 
Hello John,

I have not fully understood what do you mean when you wrote "If we had a pool of hundreds of consists, then I would think the values maybe a bit more widespread."? Having one hundred different consists listed for a single portal, or monitoring hundreds of emitted consists?

Since yesterday, I have taken 10 more samples, and the frequencies appear to be more or less constant. I will take more: if this is only a statistical anomaly, it should disappear as the number or samples increases (maybe :D).

Regards
 
Back
Top