• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

lila-laune-bär

Captain
55 Badges
Feb 14, 2005
416
11
  • Surviving Mars: Digital Deluxe Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Hearts of Iron IV: Together for Victory
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - Mass Transit
  • Knights of Honor
  • Surviving Mars
  • Hearts of Iron IV: Death or Dishonor
  • Stellaris: Synthetic Dawn
  • Age of Wonders III
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Apocalypse
  • Tyranny: Archon Edition
  • Cities: Skylines - Parklife
  • Stellaris: Distant Stars
  • Shadowrun Returns
  • Shadowrun: Dragonfall
  • Shadowrun: Hong Kong
  • Cities: Skylines Industries
  • Stellaris: Megacorp
  • Imperator: Rome
  • Hearts of Iron IV: Expansion Pass
  • Prison Architect
  • Stellaris: Ancient Relics
  • Hearts of Iron IV: No Step Back
  • Victoria 2: A House Divided
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sword of Islam
  • Commander: Conquest of the Americas
  • Europa Universalis III
  • Europa Universalis IV
  • Hearts of Iron III
  • Magicka
  • Rome Gold
  • Sword of the Stars II
  • Victoria 2
  • Crusader Kings II
  • Victoria 2: Heart of Darkness
  • Rome: Vae Victis
  • 500k Club
  • Cities: Skylines
  • Crusader Kings II: Horse Lords
  • Cities: Skylines - After Dark
  • Knights of Pen and Paper 2
  • Cities: Skylines - Snowfall
  • Stellaris
  • Stellaris Sign-up
I think the new system of "mean time to happen" is a very interesting concept. So I'm interested in how it works exactly. As I understand it, it's basically a concept of probability, and MTTH is the expected time time wait for an event to fire. Speaking of probabilty, we name it "mean".

That's nice and all, but that's only half the information. It's even more important what type of probabilty distribution we've got and what's the statistical dispersion. Is there any more information about the system available? If not, one could run write an event, which should fire very often, note when it fires and thus estimate the dispersion, which would be quite handy for modders, I believe.

My first guess would be that the game uses a normal distribution.
unbenanntkd5.jpg


Your thoughts, ideas, comments?
 
Last edited:
  • 1Like
Reactions:
I believe MTTH is a lot simpler than that. Basically if MTTH = 300, then there's 1/300'th chance of it happening each month.

Can't give you a quote for this, but I think I saw it in the wiki somewhere.
 
1/MTTH is the probability of said event happening each month independently of other months. We are thus working with an exponential distribution with parameter MTTH.

Esben
 
  • 1Like
Reactions:
Zakath said:
I believe MTTH is a lot simpler than that. Basically if MTTH = 300, then there's 1/300'th chance of it happening each month.

Can't give you a quote for this, but I think I saw it in the wiki somewhere.

esbenmf said:
1/MTTH is the probability of said event happening each month independently of other months. We are thus working with an exponential distribution with parameter MTTH.

Esben
It's as simple as that? Gosh, I thought paradox would have used a more elaborated model.

So thanks, case closed. :D

edit: But that's no exponential distribution, but a geometric distribution, if I'm not mistaken.
http://en.wikipedia.org/wiki/Geometric_distribution
 
Zakath said:
I believe MTTH is a lot simpler than that. Basically if MTTH = 300, then there's 1/300'th chance of it happening each month.

Can't give you a quote for this, but I think I saw it in the wiki somewhere.

I remember seeing the same. Thus the MTTH value of k time units maps one-to-one to the fixed probability per time unit p that has the property that

expected number of the event triggering = 1 for k time units...

[my probability math is a bit rusty but i AFAIK it's basicly a poisson process
with the intensity of p*t. Which would mean that more generally the probablity of the event triggering exactly k times in a time of t would be

P(# of triggering = k) = exp(-p*t)*((p*t)^k/k!)

]
 
MeanTimeToHappen = the value given after modifiers..
noOfDays = basically, how many days are between checks.. (currently 1)

Code:
		float daylyChance = float(1.0f - exp( log(0.5f) / MeanTimeToHappen ));
		float chance = float(1 - exp( noOfDays * log(1 - daylyChance)) );
		return chance;  //0-1% chance of event happening that day
 
Johan said:
noOfDays = basically, how many days are between checks.. (currently 1)

Is this hardcoded, or can it be defined in an event? Would be useful to have the game check for triggers in certain events with intervals. I assume it would also help on game performance if it doesn't have to check all events every day.
 
Darkrenown said:
That's source code (C++ maybe) in the box, so it's hardcoded :)

Yeah I'm aware that the content Johan posted is from the code, but perhaps there was some sort of equalent to the EU2 'offset'.
 
Johan said:
MeanTimeToHappen = the value given after modifiers..
noOfDays = basically, how many days are between checks.. (currently 1)

Code:
		float daylyChance = float(1.0f - exp( log(0.5f) / MeanTimeToHappen ));
		float chance = float(1 - exp( noOfDays * log(1 - daylyChance)) );
		return chance;  //0-1% chance of event happening that day

Thank you Johan (God of Thunder etc.)!

So it isn't simple 1/MTTH chance per time unit after all.

The above definition leads to probability p (chance_per_day) that, when checked for a time period of MTTH will result in a 0.5 (=50%) chance of the event firing at least once. So currently the wiki is wrong on this.

Let's have a concrete example: an event with a modified MTTH of 3 months. 3 months = 90 days. Log is the natural logarithm in C++.

chance per day p:
Code:
P =1-exp(log(0.5)/90)
         =1-exp(log(0.5))^(1/90)
         =1-(0.5)^(1/90)

i.e. aproximately p=0.007672053737056518974464631174 chance per day.

Since currently noOfDays=1 then chance per check is the same as daily chance.

With the above daily chance p the following holds:

1) The expected value for the number of times that the event triggers during 3 months is not 1 (as it would be if the wiki was right), but 90*p, i.e. aproximately 0.69.

2) The amount of days k that one has to wait for the event to have had a 50-50 chance of triggering (at least once) is 90 days (i.e. exactly the MTTH):

Code:
(1-p)^k=0.5
k*log(1-p) = log(0.5)
k=log(0.5)/log(1-p)
k=90
 
Last edited:
<saves this thread immediately>

I have been hoping for some time that a Paradox staffer would post the math behind the MTTH. :) Thank you for this thread!
 
Damn you. Making me dust off my calculator! It's been years since I've done any math.

The code may as well be Gree... well Swedish to me, so thank you for the little writeup Hakkapeliitta.

It looks as though that .69 probability of the event occurring once in the MTTH is constant--it doesn't matter what the MTTH is, it will always be .69. (I know there's probably a simple way to do this algebraically, but hooray for arithmetic trial and error!)

Then for the chance for the event to occur exactly once, it would just be 1/0.69=1.45.

So the wiki could just be changed to saying "The event will probably occur once by 1.45*MTTH." (As well, of course, as the code itself.)

This 1.45*MTTH is the value I suspect most players will care about.

This goes a fair bit to explaining why I only had 2 of my 5 possible Yemeni great men fire, despite the fact that they were all in office for 25+ years. (Great Men MTTH = 25 years) They would have to be in office for 36.25 years to probably fire. (And the MTTH was actually a bit higher than 25 years, since I had a couple of *1.1 penalties for narrowminded and the like.)

...

Isn't there a way to tell when an event has a 95% likelihood that it will fire within a certain period? Something with standard deviations or something like that.

So you could say "an event will fire probably once in 1.45*MTTH, but by x*MTTH, there is a 95% chance that the event will have fired." Then you could set hard end dates on when events will fire by and rely upon those in a game or mod.
 
Primus Inter Pa said:
Damn you. Making me dust off my calculator! It's been years since I've done any math.

The code may as well be Gree... well Swedish to me, so thank you for the little writeup Hakkapeliitta.

It looks as though that .69 probability of the event occurring once in the MTTH is constant--it doesn't matter what the MTTH is, it will always be .69. (I know there's probably a simple way to do this algebraically, but hooray for arithmetic trial and error!)

The expected number of the event triggering during a time period of MTTH length is

Code:
MTTH*(1-(0.5)^(1/MTTH))

which is not a constant (easy example MTTH=1 day), but in practical cases usually hangs around 0.69. One needs to bear in mind that it isn't the "chance of event happening once" but the expected value, i.e. if you tried it out 1000 times, and counted how many times the event triggered during the MTTH it would sometimes not trigger at all, sometimes many times, but the mean "number of event triggering" would be the expected value.

Isn't there a way to tell when an event has a 95% likelihood that it will fire within a certain period? Something with standard deviations or something like that.

Sure. Let's again assume that the checks are made daily. The number of checks needed for the "event having triggered at least once has 95% probability" is the same as for "the event hasn't triggered even once has 5% probability"

Code:
(1-p)^k=0.05
k=log(0.05)/log(1-p)
k=log(0.05)/log(exp(log(0.5)/MTTH))
k=(log(0.05)/log(0.5))*MTTH

log(0.05)/log(0.5) is aproximately 4.32. So the rule of thumb would be that in a period of MTTH*4.32 the event has a 95% chance of firing at least once.
 
Last edited:
So I understand that chances to event be fired are growing from day to day. What's about game reloading ? Is it enough information in save file, to not start counting from day one ? I am just waiting for Westernization and after 12 years of waiting I saved my game .... I was fulfilled all conditions but after 20 years (240 months) of waiting I still have no luck. Mayby game reloading is my problem ?
 
Last edited:
Kristof73 said:
So I understand that chances to event be fired are growing from day to day. What's about game reloading ? Is it enough information in save file, to not start counting from day one ? I am just waiting for Westernization and after 12 years of waiting I saved my game .... I was fulfilled all conditions but after 20 years (240 months) of waiting I still have no luck. Mayby game reloading is my problem ?
Given that the modifiers to MTTH do not change, the daily chance of an event firing remains constant over time. No information has to be saved what so ever, and saving/reloading does not change your "luck".
 
Kristof73 said:
So I understand that chances to event be fired are growing from day to day. What's about game reloading ? Is it enough information in save file, to not start counting from day one ? I am just waiting for Westernization and after 12 years of waiting I saved my game .... I was fulfilled all conditions but after 20 years (240 months) of waiting I still have no luck. Mayby game reloading is my problem ?
The checks are independent of each other. That is, the succes chance of the next check is not influenced by previous checks. There is no "memory" of the previous checks.

Concrete example: if you flip a coin, there's a 50-50 chance it will land heads. Just because the previous 10 flips were tails, doesn't mean that the chance of heads for the next flip will be greater than 50-50.

Example of dependent check:
A vase containing ten red marbles and one black marble. If you pulled out ten marbles and they all turn out to be red, and you don't put the red marbles back into the vase, there will be a 100% chance that the next marble will be black.

In short; no, reloading is not your problem :)