Hen Hanna:
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
---> the Most crowded room is occupied by 5 people. (A)
Your approach as faulty. The number of people in the most
crowded room is a random variable, and only, when the amount
of experiment is infinite can you rely on your simulations.
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
the Most crowded room is occupied by 5 people. (A)
Have you encountered this number (63.2 %) some time earlier ?
( i may have, but if so, i had forgotten)
and also ..........
What's the formula that gives me the expected # of ppl in the Most crowded room ( 5, 5, 22 below) ?
(is there a Web-page that explains it? ------ i couldn't find it in SE (StackExchange), etc.)
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
the Most crowded room is occupied by 5 people. (A)
1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
10000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 22 people.
---------------- what are the theoretical values for (A) and (B) ?22 above seems to be wrong.
On Wednesday, September 14, 2022 at 5:42:33 PM UTC-4, henh...@gmail.com wrote:
Have you encountered this number (63.2 %) some time earlier ? ( i may have, but if so, i had forgotten)
and also ..........
What's the formula that gives me the expected # of ppl in the Most crowded room ( 5, 5, 22 below) ?
(is there a Web-page that explains it? ------ i couldn't find it in SE (StackExchange), etc.)
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
the Most crowded room is occupied by 5 people. (A)
1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
10000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 22 people.
---------------- what are the theoretical values for (A) and (B) ?
22 above seems to be wrong.
Analytic values for 1-4 rooms:
1 --- 1
2 --- 1.5 (3/2)
3 --- 1.889 (17/9)
4 --- 2.125 (17/8)
Simulation approximate results for 10,100,1000,10000 rooms:
10 2.75
100 4.23
1000 5.52
10000 6.66
Python program for simulation:
#! python
import sys
import random
def process(bins, trials):
average = 0
counts = []
for n in range(bins):
counts.append(0)
random.seed(None)
for n in range(trials):
for m in range(bins):
counts[m] = 0
for m in range(bins):
counts[random.randint(0, bins - 1)] += 1
maximum = 0
for m in range(bins):
if counts[m] > maximum:
maximum = counts[m]
average += maximum
average /= trials
print("Average maximum bin occupation is " + str(average))
if len(sys.argv) == 3:
error = False
try:
bins = int(sys.argv[1])
trials = int(sys.argv[2])
except ValueError:
print("Number of bins and number of trials must be integers")
error = True
if not error and (bins <= 1 or trials <= 0):
if bins <= 1:
print("Number of bins must be greater than 1")
else:
print("Number of trials must be greater than 0")
error = True
if not error:
try:
process(bins, trials)
except KeyboardInterrupt:
print("Cancelled")
else:
print("Usage: RandomDrop <number-of-bins> <number-of-trials>")
Please reply to ilanlmayer at gmail dot com
__/\__
\ /
__/\\ //\__ Ilan Mayer
\ /
/__ __\ Toronto, Canada
/__ __\
||
On Wednesday, September 14, 2022 at 5:42:33 PM UTC-4, henh...@gmail.com wrote:
Have you encountered this number (63.2 %) some time earlier ?
( i may have, but if so, i had forgotten)
and also ..........
What's the formula that gives me the expected # of ppl in the Most crowded room ( 5, 5, 22 below) ?
(is there a Web-page that explains it? ------ i couldn't find it in SE (StackExchange), etc.)
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
the Most crowded room is occupied by 5 people. (A)
1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
10000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 22 people.
---------------- what are the theoretical values for (A) and (B) ?22 above seems to be wrong.
Analytic values for 1-4 rooms:
1 1
2 1.5 (3/2)
3 1.889 (17/9)
4 2.125 (17/8)
Simulation approximate results for 10,100,1000,10000 rooms:
10 2.75
100 4.23
1000 5.52
10000 6.66
Python program for simulation:
#! python
import sys
import random
def process(bins, trials):
average = 0
counts = []
for n in range(bins):
counts.append(0)
random.seed(None)
for n in range(trials):
for m in range(bins):
counts[m] = 0
for m in range(bins):
counts[random.randint(0, bins - 1)] += 1
maximum = 0
for m in range(bins):
if counts[m] > maximum:
maximum = counts[m]
average += maximum
average /= trials
print("Average maximum bin occupation is " + str(average))
if len(sys.argv) == 3:
error = False
try:
bins = int(sys.argv[1])
trials = int(sys.argv[2])
except ValueError:
print("Number of bins and number of trials must be integers")
error = True
if not error and (bins <= 1 or trials <= 0):
if bins <= 1:
print("Number of bins must be greater than 1")
else:
print("Number of trials must be greater than 0")
error = True
if not error:
try:
process(bins, trials)
except KeyboardInterrupt:
print("Cancelled")
else:
print("Usage: RandomDrop <number-of-bins> <number-of-trials>")
Please reply to ilanlmayer at gmail dot com
__/\__
\ /
__/\\ //\__ Ilan Mayer
\ /
/__ __\ Toronto, Canada
/__ __\
||
py RanDrop.py 100 100Average maximum bin occupation is 4
py RanDrop.py 1000 1000Average maximum bin occupation is 5
On Thursday, September 15, 2022 at 9:01:47 AM UTC-7, Ilan Mayer wrote:
On Wednesday, September 14, 2022 at 5:42:33 PM UTC-4, henh...@gmail.com wrote:
Have you encountered this number (63.2 %) some time earlier ? ( i may have, but if so, i had forgotten)
and also ..........
What's the formula that gives me the expected # of ppl in the Most crowded room ( 5, 5, 22 below) ?
(is there a Web-page that explains it? ------ i couldn't find it in SE (StackExchange), etc.)
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
the Most crowded room is occupied by 5 people. (A)
1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
10000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 22 people.
---------------- what are the theoretical values for (A) and (B) ?
22 above seems to be wrong.
Have you encountered this number (63.2 %) some time earlier ?
( i may have, but if so, i had forgotten)
and also ..........
What's the formula that gives me the expected # of ppl in the Most crowded room ( 5, 5, 22 below) ?
(is there a Web-page that explains it? ------ i couldn't find it in SE (StackExchange), etc.)
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
the Most crowded room is occupied by 5 people. (A)
1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
10000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 22 people.
---------------- what are the theoretical values for (A) and (B) ?
On 16/09/2022 18:36, henh...@gmail.com wrote:
On Thursday, September 15, 2022 at 9:01:47 AM UTC-7, Ilan Mayer wrote:
On Wednesday, September 14, 2022 at 5:42:33 PM UTC-4,
henh...@gmail.com wrote:
Have you encountered this number (63.2 %) some time earlier ?22 above seems to be wrong.
( i may have, but if so, i had forgotten)
and also ..........
What's the formula that gives me the expected # of ppl in the Most
crowded room ( 5, 5, 22 below) ?
(is there a Web-page that explains it? ------ i couldn't find it in
SE (StackExchange), etc.)
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
the Most crowded room is occupied by 5 people. (A)
1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
10000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 22 people.
---------------- what are the theoretical values for (A) and (B) ?
Analytic values for 1-4 rooms:
1 1
2 1.5 (3/2)
3 1.889 (17/9)
4 2.125 (17/8)
Simulation approximate results for 10,100,1000,10000 rooms:
10 2.75
100 4.23
1000 5.52
10000 6.66
Python program for simulation:
#! python
import sys
import random
def process(bins, trials):
average = 0
counts = []
for n in range(bins):
counts.append(0)
random.seed(None)
for n in range(trials):
for m in range(bins):
counts[m] = 0
for m in range(bins):
counts[random.randint(0, bins - 1)] += 1
maximum = 0
for m in range(bins):
if counts[m] > maximum:
maximum = counts[m]
average += maximum
average /= trials
print("Average maximum bin occupation is " + str(average))
if len(sys.argv) == 3:
error = False
try:
bins = int(sys.argv[1])
trials = int(sys.argv[2])
except ValueError:
print("Number of bins and number of trials must be integers")
error = True
if not error and (bins <= 1 or trials <= 0):
if bins <= 1:
print("Number of bins must be greater than 1")
else:
print("Number of trials must be greater than 0")
error = True
if not error:
try:
process(bins, trials)
except KeyboardInterrupt:
print("Cancelled")
else:
print("Usage: RandomDrop <number-of-bins> <number-of-trials>")
Please reply to ilanlmayer at gmail dot com
__/\__
\ /
__/\\ //\__ Ilan Mayer
\ /
/__ __\ Toronto, Canada
/__ __\
||
really nice... i have basically 2 comments.
in my Python code, i was stuck with the idea that i had to use a
Dictionary to do the counting (tallying up).
This (what i was doing) must be a much, MUCH slower way to do it.
dic= { }
for digit in Lis:
if (digit in dic): dic[ digit ] += 1
else: dic[ digit ] = 1
MaxVal = max(dic.values())
---------- Also, it must be a bit faster to initialize the Dictionary
to all 0's in the beginning.
__________________________________________
py RanDrop.py 100 100Average maximum bin occupation is 4
py RanDrop.py 1000 1000Average maximum bin occupation is 5
At first i was getting only integer results (as above), and i
had to insert one line
(apparently, to convert the int into a Floating Point number).
( i dn't really get it)
average *= 1.0 <----------------- (i
inserted this line.)
average /= trials
print("Average maximum bin occupation is " + str(average))
You can use a defaultdict as a counter,
from collections import defaultdict
cntr = defaultdict(int)
cntr[6] += 1
cntr[6] += 1
cntr[6]
2
cntr[1]
0
and initialise it to use the float type if you want (I wouldn't as it's
more natural for counts to be integer valued).
On Thursday, September 15, 2022 at 9:01:47 AM UTC-7, Ilan Mayer wrote:
On Wednesday, September 14, 2022 at 5:42:33 PM UTC-4, henh...@gmail.com wrote:
Have you encountered this number (63.2 %) some time earlier ?22 above seems to be wrong.
( i may have, but if so, i had forgotten)
and also ..........
What's the formula that gives me the expected # of ppl in the Most crowded room ( 5, 5, 22 below) ?
(is there a Web-page that explains it? ------ i couldn't find it in SE (StackExchange), etc.)
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
the Most crowded room is occupied by 5 people. (A)
1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
10000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 22 people.
---------------- what are the theoretical values for (A) and (B) ?
Analytic values for 1-4 rooms:
1 1
2 1.5 (3/2)
3 1.889 (17/9)
4 2.125 (17/8)
Simulation approximate results for 10,100,1000,10000 rooms:
10 2.75
100 4.23
1000 5.52
10000 6.66
Python program for simulation:
#! python
import sys
import random
def process(bins, trials):
average = 0
counts = []
for n in range(bins):
counts.append(0)
random.seed(None)
for n in range(trials):
for m in range(bins):
counts[m] = 0
for m in range(bins):
counts[random.randint(0, bins - 1)] += 1
maximum = 0
for m in range(bins):
if counts[m] > maximum:
maximum = counts[m]
average += maximum
average /= trials
print("Average maximum bin occupation is " + str(average))
if len(sys.argv) == 3:
error = False
try:
bins = int(sys.argv[1])
trials = int(sys.argv[2])
except ValueError:
print("Number of bins and number of trials must be integers")
error = True
if not error and (bins <= 1 or trials <= 0):
if bins <= 1:
print("Number of bins must be greater than 1")
else:
print("Number of trials must be greater than 0")
error = True
if not error:
try:
process(bins, trials)
except KeyboardInterrupt:
print("Cancelled")
else:
print("Usage: RandomDrop <number-of-bins> <number-of-trials>")
Please reply to ilanlmayer at gmail dot com
__/\__
\ /
__/\\ //\__ Ilan Mayer
\ /
/__ __\ Toronto, Canada
/__ __\
||
really nice... i have basically 2 comments.
in my Python code, i was stuck with the idea that i had to use a Dictionary to do the counting (tallying up).
This (what i was doing) must be a much, MUCH slower way to do it.
dic= { }
for digit in Lis:
if (digit in dic): dic[ digit ] += 1
else: dic[ digit ] = 1
MaxVal = max(dic.values())
---------- Also, it must be a bit faster to initialize the Dictionary to all 0's in the beginning.
__________________________________________
py RanDrop.py 100 100Average maximum bin occupation is 4
py RanDrop.py 1000 1000Average maximum bin occupation is 5
At first i was getting only integer results (as above), and i had to insert one line
(apparently, to convert the int into a Floating Point number). ( i dn't really get it)
average *= 1.0 <----------------- (i inserted this line.)
average /= trials
print("Average maximum bin occupation is " + str(average))
On 16/09/2022 18:36, henh...@gmail.com wrote:
On Thursday, September 15, 2022 at 9:01:47 AM UTC-7, Ilan Mayer wrote:
On Wednesday, September 14, 2022 at 5:42:33 PM UTC-4, henh...@gmail.com wrote:
Have you encountered this number (63.2 %) some time earlier ?22 above seems to be wrong.
( i may have, but if so, i had forgotten)
and also ..........
What's the formula that gives me the expected # of ppl in the Most crowded room ( 5, 5, 22 below) ?
(is there a Web-page that explains it? ------ i couldn't find it in SE (StackExchange), etc.)
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
the Most crowded room is occupied by 5 people. (A)
1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
10000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 22 people.
---------------- what are the theoretical values for (A) and (B) ?
Analytic values for 1-4 rooms:
1 1
2 1.5 (3/2)
3 1.889 (17/9)
4 2.125 (17/8)
Simulation approximate results for 10,100,1000,10000 rooms:
10 2.75
100 4.23
1000 5.52
10000 6.66
Python program for simulation:
#! python
import sys
import random
def process(bins, trials):
average = 0
counts = []
for n in range(bins):
counts.append(0)
random.seed(None)
for n in range(trials):
for m in range(bins):
counts[m] = 0
for m in range(bins):
counts[random.randint(0, bins - 1)] += 1
maximum = 0
for m in range(bins):
if counts[m] > maximum:
maximum = counts[m]
average += maximum
average /= trials
print("Average maximum bin occupation is " + str(average))
if len(sys.argv) == 3:
error = False
try:
bins = int(sys.argv[1])
trials = int(sys.argv[2])
except ValueError:
print("Number of bins and number of trials must be integers")
error = True
if not error and (bins <= 1 or trials <= 0):
if bins <= 1:
print("Number of bins must be greater than 1")
else:
print("Number of trials must be greater than 0")
error = True
if not error:
try:
process(bins, trials)
except KeyboardInterrupt:
print("Cancelled")
else:
print("Usage: RandomDrop <number-of-bins> <number-of-trials>")
Please reply to ilanlmayer at gmail dot com
__/\__
\ /
__/\\ //\__ Ilan Mayer
\ /
/__ __\ Toronto, Canada
/__ __\
||
really nice... i have basically 2 comments.
in my Python code, i was stuck with the idea that i had to use a Dictionary to do the counting (tallying up).
This (what i was doing) must be a much, MUCH slower way to do it.
dic= { }
for digit in Lis:
if (digit in dic): dic[ digit ] += 1
else: dic[ digit ] = 1
MaxVal = max(dic.values())
---------- Also, it must be a bit faster to initialize the Dictionary to all 0's in the beginning.
__________________________________________
py RanDrop.py 100 100Average maximum bin occupation is 4
py RanDrop.py 1000 1000Average maximum bin occupation is 5
At first i was getting only integer results (as above), and i had to insert one line
(apparently, to convert the int into a Floating Point number). ( i dn't really get it)
average *= 1.0 <----------------- (i inserted this line.)You can use a defaultdict as a counter,
average /= trials
print("Average maximum bin occupation is " + str(average))
from collections import defaultdict
cntr = defaultdict(int)
cntr[6] += 1
cntr[6] += 1
cntr[6]
2
cntr[1]
0
and initialise it to use the float type if you want (I wouldn't as it's
more natural for counts to be integer valued).
cntr = defaultdict(float)
cntr[6] += 1
cntr[6] += 1
cntr[6]
2.0
cntr[1]
0.0
Or there is (in sufficiently recent versions of Python) the Counter
class for counters.
from collections import Counter
cntr = Counter()
cntr[6] += 1
cntr[6] += 1
cntr[6]
2
cntr[1]
0
This also has a most_common method.
cntr[8] = 1
cntr
Counter({6: 2, 8: 1})
cntr.most_common(n=1)
[(6, 2)]
The random module has a choices function for sampling with replacement.
import random
random.choices(range(10), k=10)
[4, 6, 3, 2, 8, 7, 8, 8, 7, 0]
You could combine the above into a one-liner for sampling and finding
the maximum count.
Counter(random.choices(range(10), k=10)).most_common(n=1)[0][1]
2
Counter(random.choices(range(10), k=10)).most_common(n=1)[0][1]
3
Counter(random.choices(range(10), k=10)).most_common(n=1)[0][1]
2
total = 0
for _ in range(10000):
total += Counter(random.choices(range(10),
k=10)).most_common(n=1)[0][1]
total / 10000
2.7497
You must be using Python2 to get integer division by default. So it's probably time to install Python3. Cheers.
Duncan
Have you encountered this number (63.2 %) some time earlier ?
( i may have, but if so, i had forgotten)
and also ..........
What's the formula that gives me the expected # of ppl in the Most crowded room ( 5, 5, 22 below) ?
(is there a Web-page that explains it? ------ i couldn't find it in SE (StackExchange), etc.)
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
the Most crowded room is occupied by 5 people. (A)
1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
10000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 22 people.
---------------- what are the theoretical values for (A) and (B) ?
On Thursday, September 15, 2022 at 6:15:35 PM UTC-7, henh...@gmail.com wrote:
On Thursday, September 15, 2022 at 9:01:47 AM UTC-7, Ilan Mayer wrote:---------- 100 ppl in 100 (random) rooms --> ~ 63.2 rooms get occupied
On Wednesday, September 14, 2022 at 5:42:33 PM UTC-4, henh...@gmail.com wrote:
Have you encountered this number (63.2 %) some time earlier ? ( i may have, but if so, i had forgotten)
and also ..........
What's the formula that gives me the expected # of ppl in the Most crowded room ( 5, 5, 22 below) ?
(is there a Web-page that explains it? ------ i couldn't find it in SE (StackExchange), etc.)
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
the Most crowded room is occupied by 5 people. (A)
1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
10000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 22 people.
---------------- what are the theoretical values for (A) and (B) ?
22 above seems to be wrong.really ? waht do you propose ? (or suggest, instead) ?
i inserted two characters [*10] into your program, to find :
Crowded\iMayer> py RanDrop10.py 1000 100
Average maximum bin occupation is 21.56
Crowded\iMayer> py RanDrop10.py 1000 200
Average maximum bin occupation is 21.615
Crowded\iMayer> py RanDrop10.py 1000 400
Average maximum bin occupation is 21.6375
Crowded\iMayer> py RanDrop10.py 1000 1000
Average maximum bin occupation is 21.616
On Sunday, September 18, 2022 at 1:10:42 PM UTC-7, Ilan Mayer wrote:
On Wednesday, September 14, 2022 at 5:42:33 PM UTC-4, henh...@gmail.com wrote:
Have you encountered this number (63.2 %) some time earlier ?
( i may have, but if so, i had forgotten)
and also ..........
What's the formula that gives me the expected # of ppl in the Most crowded room ( 5, 5, 22 below) ?
(is there a Web-page that explains it? ------ i couldn't find it in SE (StackExchange), etc.)
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
the Most crowded room is occupied by 5 people. (A)
1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
10000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 22 people.
---------------- what are the theoretical values for (A) and (B) ?
The exact number for 100 people / 100 rooms is 4.23259523879579 (found by a C# program).How long is (was) the execution (run-time) for that program?
Less than 10 min. would be impressive , but it depends on how fast the PC is
i don't think i can do 1000 people / 1000+ rooms on my slow home PC
---------------- i'm starting to understand why young ppl omit the final periods1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
( seems too formal )
On Wednesday, September 14, 2022 at 5:42:33 PM UTC-4, henh...@gmail.com wrote:
Have you encountered this number (63.2 %) some time earlier ?
( i may have, but if so, i had forgotten)
and also ..........
What's the formula that gives me the expected # of ppl in the Most crowded room ( 5, 5, 22 below) ?
(is there a Web-page that explains it? ------ i couldn't find it in SE (StackExchange), etc.)
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
the Most crowded room is occupied by 5 people. (A)
1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
10000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 22 people.
---------------- what are the theoretical values for (A) and (B) ?
The exact number for 100 people / 100 rooms is 4.23259523879579 (found by a C# program).
1000 ppl are randomly assigned to 1000 rooms...
---> the Most crowded room is occupied by 5 people. (B)
On Thursday, September 15, 2022 at 9:01:47 AM UTC-7, Ilan Mayer wrote:
On Wednesday, September 14, 2022 at 5:42:33 PM UTC-4, henh...@gmail.com wrote:100 ppl in 100 (random) rooms --> ~ 63.2 rooms get occupied
Have you encountered this number (63.2 %) some time earlier ? ( i may have, but if so, i had forgotten)
and also ..........
What's the formula that gives me the expected # of ppl in the Most crowded room ( 5, 5, 22 below) ?
(is there a Web-page that explains it? ------ i couldn't find it in SE (StackExchange), etc.)
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
the Most crowded room is occupied by 5 people. (A)
1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
10000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 22 people.
---------------- what are the theoretical values for (A) and (B) ?
22 above seems to be wrong.really ? waht do you propose ?
Analytic values for 1-4 rooms:
1 --- 1
2 --- 1.5 (3/2)
3 --- 1.889 (17/9)
4 --- 2.125 (17/8)
6 --------------- 2.408179012345679
8 -------------- 2.5972328186035156
10 ------------- 2.74868911 (exact number) ----------- a very close match with what you got !
Simulation approximate results for 10,100,1000,10000 rooms:
10 2.75
100 4.23
1000 5.52
10000 6.66
Python program for simulation:
#! python
import sys
import random
def process(bins, trials):
average = 0
counts = []
for n in range(bins):
counts.append(0)
random.seed(None)
for n in range(trials):
for m in range(bins):
counts[m] = 0
for m in range(bins):
counts[random.randint(0, bins - 1)] += 1
maximum = 0
for m in range(bins):
if counts[m] > maximum:
maximum = counts[m]
average += maximum
average /= trials
print("Average maximum bin occupation is " + str(average))
if len(sys.argv) == 3:
error = False
try:
bins = int(sys.argv[1])
trials = int(sys.argv[2])
except ValueError:
print("Number of bins and number of trials must be integers")
error = True
if not error and (bins <= 1 or trials <= 0):
if bins <= 1:
print("Number of bins must be greater than 1")
else:
print("Number of trials must be greater than 0")
error = True
if not error:
try:
process(bins, trials)
except KeyboardInterrupt:
print("Cancelled")
else:
print("Usage: RandomDrop <number-of-bins> <number-of-trials>")
Please reply to ilanlmayer at gmail dot com
__/\__
\ /
__/\\ //\__ Ilan Mayer
\ /
/__ __\ Toronto, Canada
/__ __\
||
On Sunday, September 18, 2022 at 4:38:02 PM UTC-4, henh...@gmail.com wrote:
On Sunday, September 18, 2022 at 1:10:42 PM UTC-7, Ilan Mayer wrote:
On Wednesday, September 14, 2022 at 5:42:33 PM UTC-4, henh...@gmail.com wrote:
Have you encountered this number (63.2 %) some time earlier ?
( i may have, but if so, i had forgotten)
and also ..........
What's the formula that gives me the expected # of ppl in the Most crowded room ( 5, 5, 22 below) ?
(is there a Web-page that explains it? ------ i couldn't find it in SE (StackExchange), etc.)
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
the Most crowded room is occupied by 5 people. (A)
1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
10000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 22 people.
---------------- what are the theoretical values for (A) and (B) ?
The exact number for 100 people / 100 rooms is 4.23259523879579 (found by a C# program).How long is (was) the execution (run-time) for that program?
Less than 10 min. would be impressive , but it depends on how fast the PC is
It took about 8 minutes on a rather old laptop.
The time grows exponentially with the number of people/rooms, so for 1000/1000 it is not going to be feasible even on the fastest pc.
i don't think i can do 1000 people / 1000+ rooms on my slow home PC
---------------- i'm starting to understand why young ppl omit the final periods1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
( seems too formal )
On Sunday, September 18, 2022 at 2:00:19 PM UTC-7, Ilan Mayer wrote:
On Sunday, September 18, 2022 at 4:38:02 PM UTC-4, henh...@gmail.com wrote:
On Sunday, September 18, 2022 at 1:10:42 PM UTC-7, Ilan Mayer wrote:
On Wednesday, September 14, 2022 at 5:42:33 PM UTC-4, henh...@gmail.com wrote:
Have you encountered this number (63.2 %) some time earlier ?
( i may have, but if so, i had forgotten)
and also ..........
What's the formula that gives me the expected # of ppl in the Most crowded room ( 5, 5, 22 below) ?
(is there a Web-page that explains it? ------ i couldn't find it in SE (StackExchange), etc.)
according to the simulations i've done...
100 ppl are randomly assigned to 100 rooms...
the Most crowded room is occupied by 5 people. (A)
1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
10000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 22 people.
---------------- what are the theoretical values for (A) and (B) ?
The exact number for 100 people / 100 rooms is 4.23259523879579 (found by a C# program).How long is (was) the execution (run-time) for that program?
Less than 10 min. would be impressive , but it depends on how fast the PC is
It took about 8 minutes on a rather old laptop.
The time grows exponentially with the number of people/rooms, so for 1000/1000 it is not going to be feasible even on the fastest pc.
-------- The time grows [exponentially] with the number of people/rooms, (my emphasis)
i don't want to seem Nit-picky
(but we're all Puzzle Nerds here, right ?)
where N= number of people/rooms
the relevant numbers (we're concerned about) grows proportional to N^N
is that called Super-Exponential or Supra--..... or something like that ?
i don't think i can do 1000 people / 1000+ rooms on my slow home PC
---------------- i'm starting to understand why young ppl omit the final periods1000 ppl are randomly assigned to 1000 rooms...
the Most crowded room is occupied by 5 people. (B)
( seems too formal )
What's the formula that gives me the expected # of ppl in
the Most crowded room
according to the simulations i've done...
HH:
What's the formula that gives me the expected # of ppl in
the Most crowded room
according to the simulations i've done...Instead of simulation, you can compute the exact value.
Observe that allocations of p people in r rooms can be
expressed as the expanded terms of a multinomial of power p
with r terms. For example:
r p
1:2 (a)^2 = a^2
E(m) = 2 = 2
2:1 (a+b)^1 = a + b
E(m) = (1 + 1)/2 = 1
2:2 (a+b)^2 = a^2 + b^2 + ab + ba =>
E(m) = ( 2 + 2 1 + 1 )/4 = 1 1/2
3:2 (a+b)^3 = a^3 + b^3 + 3b^2a + 3ab^2
E(m) =( 3 + 3 + 3 *2 + 3 * 2)/8 = 2 1/4
2:3 (a+b+c)^2 = a^2 + b^2 + c^2 + 2 a b + 2 a c + 2 b c
E(m) = ( 2 + 2 + 2 + 2 * 1 + 2 * 1 + 2 * 1)/9 = 4/3
This is regular and easily computable by sequential
generation of the terms and their corresponding multinomial
coefficient.
--
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
henh... to Anton Shepelev:
Instead of simulation, you can compute the exact value.
Observe that allocations of p people in r rooms can be
expressed as the expanded terms of a multinomial of
power p with r terms. For example:
[...]
This is regular and easily computable by sequential
generation of the terms and their corresponding
multinomial coefficient.
can we get the fraction (expected value) for 10 ppl in 10
rooms this way ?
State your doubts, if any. I say we can, and my C program
reports:
1168918030 / 424490995 ~= 2.753693
Now, what is your result, if any?
Instead of simulation, you can compute the exact value.
Observe that allocations of p people in r rooms can be
expressed as the expanded terms of a multinomial of
power p with r terms. For example:
[...]
This is regular and easily computable by sequential
generation of the terms and their corresponding
multinomial coefficient.
really?
can we get the fraction (expected value) for 10 ppl in 10
rooms this way ?
( in the very beginning, i was thinking of something like
this... )
can we get the fraction (expected value) for 10 ppl in
10 rooms this way ?
State your doubts, if any. I say we can, and my C program
reports:
1168918030 / 424490995 ~= 2.753693
where N= number of people/rooms the relevant numbers
(we're concerned about) grows proportional to N^N
Anton Shepelev to henh...:
can we get the fraction (expected value) for 10 ppl in
10 rooms this way ?
State your doubts, if any. I say we can, and my C program
reports:
1168918030 / 424490995 ~= 2.753693
Thanks to the analytic values by Ilan Mayer, I have found an
error in my program and fixed it. My corrected analytic
values for n people in n rooms are:
1: 1 / 1 = 1.000000000000000
2: 6 / 4 = 1.500000000000000
3: 51 / 27 ~ 1.888888888888889
4: 544 / 256 = 2.125000000000000
5: 7145 / 3125 = 2.286400000000000
6: 112356 / 46656 ~ 2.408179012345679
7: 2066323 / 823543 ~ 2.509065100425843
8: 43574336 / 16777216 ~ 2.597232818603516
9: 1036922769 / 387420489 ~ 2.676478912296247
10: 27486891100 / 10000000000 = 2.748689110000000
11: 803137535321 / 285311670611 ~ 2.814948065745319
12: 25642631336400 / 8916100448256 ~ 2.875991750565768
13: 888148407804853 / 302875106592253 ~ 2.932391564951315
14: 33165208812574216 / 11112006825558016 ~ 2.984628189418768
That is the precision limit of my C program. Futher values
are approximate:
15: 3.033122027793592
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 322 |
Nodes: | 16 (0 / 16) |
Uptime: | 149:41:34 |
Calls: | 7,072 |
Calls today: | 1 |
Files: | 12,494 |
Messages: | 5,499,420 |