Wizard
Administrator
Wizard
Joined: Oct 14, 2009
  • Threads: 1332
  • Posts: 21932
September 12th, 2020 at 7:37:46 AM permalink

My latest answer, about the 6th or 7th, is apx. 1.6931468.

Last edited by: Wizard on Sep 12, 2020
It's not whether you win or lose; it's whether or not you had a good bet.
TinMan
TinMan
Joined: Nov 17, 2009
  • Threads: 13
  • Posts: 128
September 12th, 2020 at 4:27:55 PM permalink
My approach when it comes to math questions I donít understand, is to guess Pi. Pi comes up in lots of weird unexpected places. Eventually Iíll be right.
If anyone gives you 10,000 to 1 on anything, you take it. If John Mellencamp ever wins an Oscar, I am going to be a very rich dude.
Ace2
Ace2
Joined: Oct 2, 2017
  • Threads: 21
  • Posts: 680
September 12th, 2020 at 5:05:59 PM permalink
Quote: TinMan

My approach when it comes to math questions I donít understand, is to guess Pi. Pi comes up in lots of weird unexpected places. Eventually Iíll be right.

This time you might be on the right track
Itís all about making that GTA
Wizard
Administrator
Wizard
Joined: Oct 14, 2009
  • Threads: 1332
  • Posts: 21932
September 13th, 2020 at 4:07:34 AM permalink
I stand by the answer I submitted before. It turns out to be 1+ln(2) = 1.693147181.



First, it takes on average one year for somebody to turn on the first bulb.

Then consider the situation where the next event is that first bulb burns out. I won't get into why this works, because the method has been discussed in many of the craps side bet threads, but the expected time until that event equals:

Integral from 0 to infinity of pr(0 new light bulbs turned on over time t)*pr(first light bulb still on over time t)*(1/2) dt. =
Integral from 0 to infinity of exp(-t)*exp(-t)*t*(1/2) dt. = 1/8

Why the 1/2? It is because the probability the next significant event will be a bulb burning out, as opposed to another bulb being turned on.

Next, consider the expected time when a second bulb gets turned on after the first and then either goes out. This is equal to:

Integral from 0 to infinity of pr(1 new light bulbs turned on over time t)*pr(first light bulb still on over time t)*(1/2) dt. =
Integral from 0 to infinity of exp(-t)*exp(-t)*t^2*(2/3) dt. = 1/6

The general formula for the expected time when x bulbs get turned on, not including the first, before one goes out =
Integral from 0 to infinity of pr(x new light bulbs turned on over time t)*pr(no light bulbs burn out over time t)*(x+1)/(x+2) dt
Integral from 0 to infinity of exp(-t)*exp(-t)*t^x*((x+1)/(x+2)) dt

Here is a table showing the expected time by number of bulbs turned on after the first.

Bulbs turned on after first Expected time
0 0.125000
1 0.166667
2 0.140625
3 0.100000
4 0.065104
5 0.040179
6 0.023926
7 0.013889
8 0.007910
9 0.004439
10 0.002462
11 0.001352
12 0.000737
13 0.000399
14 0.000215
15 0.000115
16 0.000061
17 0.000033
18 0.000017
19 0.000009
20 0.000005
21 0.000003
22 0.000001
23 0.000001
24 0.000000
Total 0.693147


Add one for the time it takes to turn on the first bulb and you're at 1.693147.

This turns out to be 1+ln(2).

To do the integration, I recommend www.integral-calculator.com/.

It's not whether you win or lose; it's whether or not you had a good bet.
Wizard
Administrator
Wizard
Joined: Oct 14, 2009
  • Threads: 1332
  • Posts: 21932
September 14th, 2020 at 9:19:57 PM permalink
A simulation, which is not easy to do with this problem, is getting a different answer, which I'll put in spoiler tags. Let's just say my confidence level is not as high.


1.718 years.

I'll run a longer simulation overnight to get more significant digits.
It's not whether you win or lose; it's whether or not you had a good bet.
Wizard
Administrator
Wizard
Joined: Oct 14, 2009
  • Threads: 1332
  • Posts: 21932
September 15th, 2020 at 4:13:30 AM permalink
I think we can quit putting comments in spoiler tags. Here is the result of a longer simulation.

Trials = 34570000000
Total time =59401299162
Average time = 1.718290401

This is very close to e-1.

I've been communicating with ace2 via PM and he gets to e-1 directly. He should get the credit for solving it first. I'll let him explain the method. It's embarrassing I didn't do it his way to begin with.

Here is my simulation code, in case anyone is interested.



void light_bulb1(void)
{
__int64 count;
int nummin, stop;
double t, burn_out, next_burn_out,tot_time, next_turn_on;
unsigned int rn1,rn2;
time_t curtime, endtime;
cerr << "Enter number of minutes in simulation: ";
cin >> nummin;
curtime = time(NULL);
endtime = curtime + (60 * nummin);
count = 0;
tot_time = 0;
do
{
count++;
rn1 = max(1,genrand_int32());
t = -1*log(((double)rn1) / 4294967296.0); // time until first bulb is turned on
rn2 = max(1, genrand_int32());
burn_out = -1 * log((double)rn2 / 4294967296.0); // time until bulb burns out
stop = 0;
do
{
rn1 = max(1, genrand_int32());
next_turn_on = -1 * log(((double)rn1) / 4294967296.0);
if (next_turn_on > burn_out)
stop = 1;
else
{
t += next_turn_on;
burn_out -= next_turn_on;
rn2 = max(1, genrand_int32());
next_burn_out = -1 * log(((double)rn2) / 4294967296.0);
if (next_burn_out < burn_out)
burn_out = next_burn_out;
}
}
while (stop == 0);
t += burn_out;
tot_time += t;
if (count % 5000000 == 0)
{
curtime = time(NULL);
cerr << "Time remaining: " << (float)(endtime - curtime) / 60 << "\n";
// printf ("%I64i\t%f\t%f\n",count,tot_time,tot_time/(double)count);
}
}
while (curtime < endtime);
printf("count=\t%I64i\n", count);
printf("Total time=\t%f\n", tot_time);
printf("average time=\t%f\n", tot_time/(double)count);
return;
}
It's not whether you win or lose; it's whether or not you had a good bet.
Ace2
Ace2
Joined: Oct 2, 2017
  • Threads: 21
  • Posts: 680
September 15th, 2020 at 7:33:45 AM permalink
I originally thought the answer was related to pi but then I thought of a much simpler solution. It was like a light bulb came on in my head, haha

Starting from first light bulb lit, there is a 1/2 year avg waiting time until next event (new bulb or burnout). Then there is a 1/2 chance weíre done and a 1/2 chance we go to 2 bulbs. From there itís 1/3 year avg waiting time until the next event. Then there is a 2/3 chance weíre done and 1/3 chance we go to 3 bulbs. And so on

Using a system of linear equations:

x = 1/2 + 1/2a
a = 1/3 + 1/3b
b = 1/4 + 1/4c
c = 1/5 + 1/5d
etc

The system evaluates to 1/2 + 1/6 + 1/24... = 1/2! + 1/3! + 1/4!....which equals (surprise surprise) e minus 2 or about 0.718. Add 1 for the year it takes for first bulb to light for e -1 = 1.718 average years for the first bulb to burn out

Thanks to the Wizard for confirming the solution with the simulation. The simulation was probably more difficult than the problem itself
Last edited by: Ace2 on Sep 15, 2020
Itís all about making that GTA
Wizard
Administrator
Wizard
Joined: Oct 14, 2009
  • Threads: 1332
  • Posts: 21932
September 15th, 2020 at 9:10:23 AM permalink
Quote: Ace2

Thanks to the Wizard for confirming the solution with the simulation. The simulation was probably more difficult than the problem itself



You're welcome.

Yes, it was a tricky simulation to do properly. I would hate to say how much time I spent on this problem between a calculus solution that was evidently wrong and then the simulation.
It's not whether you win or lose; it's whether or not you had a good bet.
Ace2
Ace2
Joined: Oct 2, 2017
  • Threads: 21
  • Posts: 680
September 15th, 2020 at 11:49:59 AM permalink
I did my simulation in excel.

First I split a year into 10,000 units with each unit having a 1 in 10,000 of a light bulb coming on. I went out 100,000 units (10 years) and kept a cumulative total of light bulbs on. The expected number of bulbs turned on after 10 years is 10 (same as exponential distribution) and the chance of no bulbs being turned on is 1 in 22,037, not exactly the exponential distribution but very close to 1/e^10 = 1 in 22,026

The probability a bulb goes out changes as the cumulative number turned on increases. If 3 are on, then the probability one goes out in the next iteration is 1 - (1 - 1/10,000)^3

Finally a vlookup for when the first bulb went out (only 1 in 22000 chance one hasnít gone out after 10 years)

Itís a simple simulation but 400,000 rows. I could do a max of 100 trials (columns) per calculation without my computer freezing up. But even after 100 x 200 = 20,000 trials, the answer was just starting to converge to 1.72.
Itís all about making that GTA

  • Jump to: