ChristianSt
2014-04-25, 03:57 AM
While I'm not sure if it really solves your problem (since the posts assignments of multiple persons are not independent from each other - at least if I understand correctly), I wrote a Python program to figure out the exact probabilities using a Markov Chain. The only rounding that is done was the division in the end to get the final result (so I have "# of successful states"/"# of total sates", each state having the same probability).
The probability of doing any task 6 or more times is 0.000135914578989 (which isn't far of from what I previously have thought).
[The exact result is 102879716273711701/756943935220796320321 ]
I have also a list of doing a task exactly N times:
Probability of doing the most frequent(s) post(s) exactly 1 times after 15 days is 0.0167485327755
Probability of doing the most frequent(s) post(s) exactly 2 times after 15 days is 0.662140058327
Probability of doing the most frequent(s) post(s) exactly 3 times after 15 days is 0.286857498906
Probability of doing the most frequent(s) post(s) exactly 4 times after 15 days is 0.0317756885253
Probability of doing the most frequent(s) post(s) exactly 5 times after 15 days is 0.00234230688761
Probability of doing the most frequent(s) post(s) exactly 6 times after 15 days is 0.000130146041241
Probability of doing the most frequent(s) post(s) exactly 7 times after 15 days is 5.57769641972e-06
Probability of doing the most frequent(s) post(s) exactly 8 times after 15 days is 1.85923214985e-07
Probability of doing the most frequent(s) post(s) exactly 9 times after 15 days is 4.82023149962e-09
Probability of doing the most frequent(s) post(s) exactly 10 times after 15 days is 9.64046299925e-11
Probability of doing the most frequent(s) post(s) exactly 11 times after 15 days is 1.46067621201e-12
Probability of doing the most frequent(s) post(s) exactly 12 times after 15 days is 1.6229735689e-14
Probability of doing the most frequent(s) post(s) exactly 13 times after 15 days is 1.24844120684e-16
Probability of doing the most frequent(s) post(s) exactly 14 times after 15 days is 5.94495812783e-19
Probability of doing the most frequent(s) post(s) exactly 15 times after 15 days is 1.32110180618e-21
So getting a task 5times is roughly 20 times more likely than getting a task 6 times.
The import thing is that I try to set a number of states which correspond to the things that can happen in the experiment.
Since we don't care about which post gets assigned, but only on how many posts get assigned how many times, I can reduce the amount of states by a pretty large factor. I don't need to compute all 31^15 possibilities, but after 15 days there is only a space of 176 states, which is manageable. And after arriving at those states I can simple group them together by categories (a post assigned exactly N times).
Basically the important part is how the state space is set up, and to figure out how you transit from state to state.
I use a list, the first number is how often this state has occurred.
Each cell N with content x after that says "This state has x posts which where assigned N times.
To get a probability you can simple divide through the number of total outcomes (which equals posts^days).
>>> After 1 days:
>>> [31, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
So after the first day there are 31 different outcomes. Each contains a single different pots.
>>> After 2 days:
>>> [930, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>> [31, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
After the second they the single state "splits" into two:
The more likelier outcome though is to get a different post: 30*31=930 cases of 2 different posts.
The other outcome is in 1 of those 31 cases you get the same post, yielding 1*31=31 outcomes with same post twice.
>>> After 3 days:
>>> [26970, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>> [2790, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>> [31, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Now it starts to get "messier":
From the first state of day two it is possible two it the first two states of day:
In 29 cases (so 29*930=26790) you have 3 different posts.
In 2 cases (so 2*930=1860) you have one post 2 times and one post 1 time.
So why there are 2790 outcomes and not 1860? Because it is also possible to hit this outcome after getting two times the same post after two days: In 30 cases you don't hit that post again, so you add another 30*31=930 outcomes to that case. 930+1860=2790.
Also in 1 case you still have a single posts assigned, yielding in 31 outcomes with 3 times a single post.
To make a good computation out of it, there only needs to be a rather easy transition rule for the state space, which can be found easily and is this:
Basically from <X, Y, Z, 0>=<X post assigned 1 time, Y post assigned 2 times, Z post assigned 3 times, 0 post assigned 4 or more times> you go
into the state <X+1, Y, Z, 0> with probability [P-(X+Y+Z)]/P
into the state <X-1, Y+1, Z, 0> with probability X/P
into the state <X, Y-1, Z+1, 0> with probability Y/P
into the state <X, Y, Z-1, 1> with probability Z/P
Where P is the total number of posts (so 31).
Theoretically it is possible to continue this without a computer, but it gets harder with each step. For example the complete state space after day 15 is this:
(From there you can compute the probability for each of those states, by dividing the first number by the number of total outcomes (=31^15).
You can/should ignore the "L", it only signalizes that this is a long and not an int (because the number is too big for a regular int).)
After 15 days:
[393008709555221760000L, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[2427406735488134400000L, 13, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[5259381260224291200000L, 11, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[5074841566883088000000L, 9, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[2283678705097389600000L, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[456735741019477920000L, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[34601192501475600000L, 3, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[644742717418800000, 1, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[584375695580476800000L, 12, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[2029936626753235200000L, 10, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[2283678705097389600000L, 8, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[1014968313376617600000L, 6, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[173005962507378000000L, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[9026398043863200000, 2, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[62683319749050000, 0, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[169161385562769600000L, 9, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[289990946679033600000L, 7, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[138404770005902400000L, 5, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[20058662319696000000L, 3, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[626833197490500000, 1, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[10252205185622400000L, 6, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[6686220773232000000, 4, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[835777596654000000, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[11143701288720000, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[92864177406000000, 3, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[11143701288720000, 1, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[28573593048000, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[92269846670601600000L, 11, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[253742078344154400000L, 9, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[217493210009275200000L, 7, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[69202385002951200000L, 5, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[7521998369886000000, 3, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[188049959247150000, 1, 5, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[36248868334879200000L, 8, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[46134923335300800000L, 6, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[15043996739772000000L, 4, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[1253666394981000000, 2, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[12536663949810000, 0, 4, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[2005866231969600000, 5, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[835777596654000000, 3, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[50146655799240000, 1, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[11143701288720000, 2, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[428603895720000, 0, 1, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[1647675833403600000, 7, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[1504399673977200000, 5, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[313416598745250000, 3, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[12536663949810000, 1, 3, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[104472199581750000, 4, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[25073327899620000, 2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[482179382685000, 0, 2, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[321452921790000, 1, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[1392962661090000, 3, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[160726460895000, 1, 1, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[1984277295000, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[10149683133766176000L, 10, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[21749321000927520000L, 8, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[13840477000590240000L, 6, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[3008799347954400000, 4, 3, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[188049959247150000, 2, 4, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[1504399673977200, 0, 5, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[2636281333445760000, 7, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[2407039478363520000, 5, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[501466557992400000, 3, 2, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[20058662319696000, 1, 3, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[83577759665400000, 4, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[20058662319696000, 2, 1, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[385743506148000, 0, 2, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[171441558288000, 1, 0, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[200586623196960000, 6, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[125366639498100000, 4, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[15043996739772000, 2, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[192871753074000, 0, 3, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[6686220773232000, 3, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[771487012296000, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[4762265508000, 0, 0, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[96435876537000, 2, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[3571699131000, 0, 1, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[5014665579924000, 5, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[2005866231969600, 3, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[115723051844400, 1, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[77148701229600, 2, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[2857359304800, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[1428679652400, 1, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[3401618220, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[805530407441760000, 9, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[1318140666722880000, 7, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[601759869590880000, 5, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[83577759665400000, 3, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[2507332789962000, 1, 4, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[133724415464640000, 6, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[83577759665400000, 4, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[10029331159848000, 2, 2, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[128581168716000, 0, 3, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[2228740257744000, 3, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[257162337432000, 1, 1, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[1058281224000, 0, 0, 3, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[8357775966540000, 5, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[3343110386616000, 3, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[192871753074000, 1, 2, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[128581168716000, 2, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[4762265508000, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[1190566377000, 1, 0, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[334311038661600, 4, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[77148701229600, 2, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[1428679652400, 0, 2, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[1904906203200, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[17008091100, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[4286038957200, 3, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[476226550800, 1, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[5669363700, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[47076452382960000, 8, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[57310463770560000, 6, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[17909519928300000, 4, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[1432761594264000, 2, 3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[13776553791000, 0, 4, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[4775871980880000, 5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[1910348792352000, 3, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[110212430328000, 1, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[36737476776000, 2, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[1360647288000, 0, 1, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[238793599044000, 4, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[55106215164000, 2, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[1020485466000, 0, 2, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[1360647288000, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[6074318250, 0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[7347495355200, 3, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[816388372800, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[9718909200, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[136064728800, 2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[4859454600, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[694207800, 1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0]
[2046802277520000, 7, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[1790951992830000, 5, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[358190398566000, 3, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[13776553791000, 1, 3, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[119396799522000, 4, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[27553107582000, 2, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[510242733000, 0, 2, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[340161822000, 1, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[4592184597000, 3, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[510242733000, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[6074318250, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[102048546600, 2, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[3644590950, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[1214863650, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[5984550, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0]
[66331555290000, 6, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
[39798933174000, 4, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
[4592184597000, 2, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
[56693637000, 0, 3, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
[2040970932000, 3, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
[226774548000, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
[1349848500, 0, 0, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
[56693637000, 2, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
[2024772750, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
[809909100, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
[4654650, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0]
[1591957326960, 5, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
[612291279600, 3, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
[34016182200, 1, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
[22677454800, 2, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
[809909100, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
[404954550, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
[2792790, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
[27831421800, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
[6184760400, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
[110442150, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
[147256200, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
[1269450, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
[343597800, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]
[36814050, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]
[423150, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]
[2831850, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]
[97650, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]
[13950, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
[31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
If you want to check other parameters (though I'm not sure how well it scales, but I tried it for 30 days which did take 50 seconds on my PC. 15 days take less than 1 second, so I wouldn't except to compute 100 days in a reasonable time) or my code/logic, here it is (though it isn't really good commented and I'm not sure how good my Python is, this is basically the first program I wrote in Python):
#!/usr/bin/env python
import copy
from time import time
from fractions import gcd
import sys
days = int(sys.argv[1]) if len(sys.argv) > 1 else 15 # First command line argument
posts = int(sys.argv[2]) if len(sys.argv) > 2 else 31 # Second command line argument
success = int(sys.argv[3]) if len(sys.argv) > 3 else 6 # Third command line argument
class state(object):
"""
Represents a state for the Markov Chain
"""
def __init__(self):
self.internal_state = [1]
"""
internal_state[0] = count
internal_state[n] = number of posts that occur exactly n times; n <= days
"""
for i in range(days):
self.internal_state.append(0);
"""access number of posts that occured exactly n times"""
def get_posts(self,n):
if n<=0 or n>days:
raise NameError("invalid n")
return self.internal_state[n]
def add_posts(self,n,k):
if n<=0 or n>days:
raise NameError("invalid n")
self.internal_state[n] += k
"""access how often this state appears"""
def get_count(self):
return self.internal_state[0]
def add_count(self,k):
self.internal_state[0] += k
def multiply_count(self,k):
self.internal_state[0] *= k
"""prints state"""
def out(self):
print(self.internal_state)
"""returns True iff states have an equal distribution of posts"""
def equal_posts(self,other):
for i in range(days):
if self.get_posts(i+1) != other.get_posts(i+1):
return False
return True
"""compares states using the post distribution"""
def compare_posts(lhs,rhs):
for i in range(days):
if lhs.get_posts(days-i) > rhs.get_posts(days-i):
return 1
elif lhs.get_posts(days-i) < rhs.get_posts(days-i):
return -1
return 0
def main():
start = time()
successes = 0
markov_chain = [[state()]]
"""main loop: iterates step after step"""
for i in range(days):
markov_chain.append(new_step(markov_chain[i]))
markov_chain[i+1] = shrink_states(markov_chain[i+1])
print("After "+str(i+1)+" days:")
for s in markov_chain[i+1]:
s.out()
print("")
end_result = compress_states(markov_chain[i+1])
"""prints some fun stuff"""
print(end_result)
print("")
for i in range(1,days+1):
if i>=success:
successes += end_result[i]
print("Probability of doing the most frequent(s) post(s) exactly "+str(i)+" times after "+str(days)+" days is "+str(1.0*end_result[i]/end_result[0]))
print("")
print("Probability of doing a post at least "+str(success)+" times after "+str(days)+" days is "+str(1.0*successes/end_result[0]))
print("Exact result = " +str(successes)+"/"+str(end_result[0]))
gcd_t = gcd(successes,end_result[0])
print("Greatest Common Divisor is "+str(gcd_t))
print("Exact result = " +str(successes/gcd_t)+"/"+str(end_result[0]/gcd_t))
print("")
print("--- Variables used ---")
print("Days = "+str(days))
print("Posts = "+str(posts))
print("Success = "+str(success))
end = time()
print("")
print("time elapsed = "+str(end-start))
def new_step(state_array):
"""
Returns the new step of the Markov Chain
"""
new_step_array = []
for s in state_array:
left_posts = posts
"""For each outcome that has already a post"""
for i in range(1,days):
if s.get_posts(i)>0:
temp_state = copy.deepcopy(s)
temp_state.add_posts(i,-1)
temp_state.add_posts(i+1,1)
temp_state.multiply_count(s.get_posts(i))
left_posts -= s.get_posts(i)
new_step_array.append(temp_state)
"""Not all posts have appeared yet"""
if left_posts>0:
temp_state = copy.deepcopy(s)
temp_state.add_posts(1,1)
temp_state.multiply_count(left_posts)
new_step_array.append(temp_state)
return new_step_array
def shrink_states(state_array):
"""
Sorts ands summarizes the states to a more compact form
"""
state_array.sort(state.compare_posts)
found_something = True
start_i = 0
while found_something:
found_something = False
for i in range(start_i,len(state_array)-1):
"""Same states are added together"""
if state_array[i].equal_posts(state_array[i+1]):
state_array[i].add_count(state_array[i+1].get_count())
state_array.remove(state_array[i+1])
found_something = True
start_i = i
break
return state_array
def compress_states(state_array):
"""
Compresses states to a single list with the first cell the total combinations.
Each cell N after that lists the amount of combinations having exactly N max posts.
"""
state_array = shrink_states(state_array)
end_result = [0]
for i in range(days):
end_result.append(0);
i = days
while i>0 and len(state_array)>0:
if state_array[-1].get_posts(i)>0:
end_result[0] += state_array[-1].get_count()
end_result[i] += state_array[-1].get_count()
state_array.pop()
continue;
i -= 1
return end_result
if __name__=="__main__":
main()
So from that for a independent drawing the chances for that event (working a post on 6 days) for 200 people is around 2-3%. [My desktop calculator says that 1−(1−102879716273711701/756943935220796320321)^200=0.026818583]
I have no clue how the dependency factors in. I would assume it increases that percentage, but from what NichG said it could also be smaller.
Edit: Yeah it doesn't scale too well. 35 days nearly takes 5 minutes. It would probably save a decent amount to introduce a final state if only really interested in "done a post X or more times", because that would greatly reduce the number of states. For the initial problem for day 15 it would reduce the number of states form 176 to 86. So that should vastly improve performance in the long run. (But since this isn't the question, I'm unlikely to optimize that program.)
Powered by vBulletin® Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.