# Probability of seeing sun rise tomorrow using Bayes theorem

When Richard Price's published the Bayes theorem, he gave the example of a man seeing the sun-rise for the first time and wondering if it happened everyday. With each observation thereafter, he updates his belief (i.e. the sun does rise everyday) using Bayesian reasoning. This question tries to analyze the same problem.

It is a stormy night and an alien prisoner is abandoned on the frigid earth during the first ice age. He came from the dark side of a tidally-locked planet (i.e. one side always faces its star and the other side is forever dark). On his planet, days are not tied to the sun, but time (24 hours is measured as a day). Now, left to die on this unknown planet Earth, he is scared and finds a cave, only coming out for a few hours at night to find some food. He has no luck though. After spending 6 nights like this, hunger becomes unbearable and so on the 7th night he decides to venture out for a little longer. After a few hours, he sees the skies changing colors. The only time he saw them change color before was during thunderstorm lightning on the night he was dropped. This time, however, he witnesses a glorious sunrise. As the warmth soothes him, he wonders if this is an one off event on earth or if the sun will rise again tomorrow. How can he use Bayes theorem to update his beliefs?

Bayes Theorem

Total number of nights observed = 7

Total number of times sky changed colors = 2 (once due to lightning and once due to sunrise)

Total number of times the sunrise happened = 1

P(belief | observation) = P(observation | belief) x P(belief) / P(observation)

P(Belief) = The sun will rise tomorrow

P(Observation) = Sky changed colors

P(Sun will rise | Sky changed color) = P (Sky changed color | Sun will rise) * P (Sun will rise) / P(Sky changed color)

Day 2

P(Sun will rise | Sky changed color) = (1/2) * (1/7) / (2/7)

= 0.25

Day 3

P(Sun will rise | Sky changed color) = (2/3) * 0.25 / (3/8)

= 0.44

Day 4

P(Sun will rise | Sky changed color) = (3/4) * 0.44 / (4/9)

= 0.74

Day 5

P(Sun will rise | Sky changed color) = (4/5) * 0.74 / (5/10)

= 1.184

Why does the posterior probability go beyond 1? What am I doing wrong here?

• Your 0.25 in Day 2 results is not P(Sun will rise), as it is used in the day 3 calculations, but P(Sun will rise | Sky changes color). That may help... Commented May 20, 2022 at 18:43
• How does the alien have a concept of "tomorrow" without understanding day/night cycles? This matters, because without a "tomorrow" it becomes a continuous-time problem; will the sun ever rise again, or perhaps will it rise within some fixed time interval that probably will not correspond to the length of a day... Commented May 30, 2022 at 2:29
• How does the alien know that he is coming out to hunt "at night"? How does he know that he has been in the cave for six "nights"? Commented May 31, 2022 at 19:26
• I cannot follow your calculations, because they don't seem to conform to the basic formula. Is it possible you are confounding the conditional probabilities of sunrises with their unconditional probabilities?
– whuber
Commented Jun 3, 2022 at 15:55
• Tangential to the actual question, but tidally locked bodies do rotate on their axes, at the same rate as their revolution - as they orbit, they must also rotate to keep the same side facing the center. A non-rotating body would have a "day" length equal to its year length, with one sunrise and one sunset for each complete orbit. Commented Jun 3, 2022 at 17:34

This is an extended comment rather than an answer. I don't think I understand your intention, but I'll show how I interpret the question as it's now written and how I would solve it. Maybe that will help you clarify what you're asking.

Let $$A$$ be the event "the sun rises", $$A^c$$ be "no sunrise", $$B$$ be "the sky changes color", and $$B^c$$ be "no change in color. The data observed for the first 7 days are the events (say the lightning happened on the third day)
$$A^cB^c$$, $$A^cB^c$$, $$A^cB$$, $$A^cB^c$$, $$A^cB^c$$, $$A^cB^c$$, $$AB$$

We now begin observing $$AB$$ every day, and want to find $$P(A|B)$$, the probability that the sun will rise given the sky changes color. I would use the definition of conditional probability, $$P(A|B) = P(A,B)/P(B)$$.

When we wake up on Day 8, we have 7 days of previous data and we calculate
$$P(A|B) = P(A,B)/P(B) = (1/7)/(2/7) = 1/2$$

On Day 9 we add the value $$AB$$ to the previous data
$$P(A|B) = P(A,B)/P(B) = (2/8)/(3/8) = 2/3$$

Day 10
$$P(A|B) = P(A,B)/P(B) = (3/9)/(4/9) = 3/4$$

Etc. These values converge to 1, as expected.

We could also use $$P(A|B) = P(B|A)P(A)/P(B)$$. Notably, in this example $$P(B|A) = 1$$

Day 8
$$P(A|B) = P(B|A)P(A)/P(B) = \frac{(1/1)(1/7)}{(2/7)} = 1/2$$

Day 9
$$P(A|B) = P(B|A)P(A)/P(B) = \frac{(2/2)(2/8)}{(3/8)} = 2/3$$

Day 10
$$P(A|B) = P(B|A)P(A)/P(B) = \frac{(3/3)(3/9)}{(4/9)} = 3/4$$

I will also remark that in your "Day 2" calculation, you use P(Sky changes color | Sun will rise) = 1/2, which is incorrect. I don't follow your calculations for Day 3 and beyond.

Further example showing updating with new independent information, similar to this youtube video from comments. Let $$C$$ be the event "the moon is visible", and assume that $$C$$ is appropriately independent of $$B$$ and independent of $$B$$ given $$A$$.

As the alien is exploring on the 9th day he finds a record from a previous traveler that says "The moon was visible on only 20% of the days when the sun rose" and "the moon is visible 40% of the time". That is, $$P(C|A) = 0.2$$, $$P(C) = 0.4$$. When the alien wakes up on the 10th day he observes the sky changing color, that is, he observes $$B$$. He calculates the probability of seeing the sun rise later that day as $$3/4$$ as above. Then he notices that he can see the moon, which he wasn't paying attention to before. He decides to use the traveler's information to update his belief. His prior probability of the sun rising (given he has already seen $$B$$) was 0.75.

$$P(A|C) \approx P(C|A)P(A)/P(C) = \frac{0.2 * 0.75}{0.4} = 0.375$$

This calculation was not really correct. What we were trying to calculate was $$P(A|B,C)$$, the probability of a sunrise given we've seen the sky change color and have seen the moon. Depending on exactly what independence assumptions between $$B$$ and $$C$$ are available the calculation we performed may be reasonable or may not be.

If we actually calculate $$P(A|C)$$, that would be assuming that we can see the moon but have not seen whether the sky changes color yet. On day 10 we've observed the sun rise 3 out of 9 times, so $$P(A) = 3/9$$. Doing that calculation gives

$$P(A|C) = P(C|A)P(A)/P(C) = \frac{0.2*(3/9)}{0.4} = 0.167$$

Clearly stating exactly what you're calculating and assuming is necessary to get the correct value and communicate it correctly.

• Thanks for your elaborate answer! Looks like I have been considering P(B|A) and P(B,A) to be the same thing, which after going through your calculations, seems incorrect. Here is what I've understood from your answer: P(B|A) means "B occurring given A", while P(B,A) means P(B /\ A). Therefore, on the 8th day in your example, P(B,A) is 1/7 because we saw the sunrise and skies changed colors together for a total of 7 days. P(B | A) = 1/1, because given that the sun rise was already observed, the skies had changed color (and continued to do so for the rest of the days). Commented Jun 4, 2022 at 16:11
• My only question left is why don't we replace the prior of day 9 with the posterior of day day 8? I have seen many online lectures do that, including this Youtube video (timestamp 5:38) (youtube.com/watch?v=R13BD8qKeTg&t=125s) Commented Jun 4, 2022 at 16:14
• Here too, the most voted answer calls "posterior" to be a revised "prior" for the upcoming events (math.stackexchange.com/questions/1823669/…). So for day 9, why not use P(A) = (1/2), and for day 10, P(A) = (2/3) and so on. Commented Jun 4, 2022 at 16:20
• @Batool Your understanding of notation is correct. To be direct, the reason we don't replace P(A) with P(A|B) is that they are different things. I added an example with a new event C that tries to show the difference. The youtube video you liked is a bit sloppy in that regard. He says the tests are independent, but doesn't really talk about it. Commented Jun 4, 2022 at 19:33
• Thank you so much for the detailed commentary! Commented Jun 4, 2022 at 20:03

First, a simplification. The event "the sky changes color" is actually irrelevant to this problem, since the individual is not concerned with whether or not the sky changes color, either as an outcome or as a conditioning event. Consequently, we can ignore it; the data then becomes seven observations, assumed independent and identically distributed, with one of those observations being a sunrise and the other six not. This will give us a $$\mathrm{Binomial}(7,p)$$ likelihood for the probability parameter $$p$$ at the end of the seven days.

We have to assume some prior distribution on $$p$$ at the start of the seven days. Given the background of the individual, $$p=0$$ would be not unreasonable, but we will ignore this and select an arbitrary $$\mathrm{Beta}(a,b)$$ prior, with $$a,b > 0$$. Since the prior is conjugate, the posterior, given a single day's observation $$x \in \{0,1\}$$ where $$1$$ represents sunrise and $$0$$ represents no sunrise, will be a $$\mathrm{Beta}(a+x, b+1-x)$$ distribution.

After day 1, the posterior will be a $$\mathrm{Beta}(a,b+1)$$ distribution. This then becomes the prior for day 2.

After day 2, the posterior will be a $$\mathrm{Beta}(a,b+2)$$ distribution. We have added one "failure" to the second parameter of the Beta prior, which has parameters $$(a,b+1)$$. This then becomes the prior for day 3. Note that this is exactly the same posterior we would have had with our initial prior and two days of no sunrise added in one step instead of sequentially.

...

After day 7, the posterior will be a $$\mathrm{Beta}(a+1,b+6)$$ distribution. We will have sequentially added six "failures" to $$b$$ and $$1$$ "success" to $$a$$.

Let us compare with the results of a one-step update of the original prior with all seven days of information:

$$f'(p) \propto p^{a-1}(1-p)^{b-1} \times p^1(1-p)^6 = p^a(1-p)^{b+5}$$

which is a $$\mathrm{Beta}(a+1, b+6)$$ distribution, the same functional form and parameterization we see if we add the seven days of information one at a time.

• Thank you for the great answer and yes, I agree that "sky changing colors" maybe irrelevant here. While there are multiple ways to solve this problem, the purpose of the question was to use Naive Bayes to solve it. When Richard Price first published the Bayes Theorem, he used a similar example to explain the theorem (i.e a cave-man seeing the sunrise for the first time and wondering if happens everyday). I tried following his analogy, but was not able to properly use Bayes Theorem with multiple iterations. Commented Jun 4, 2022 at 17:52

Statistics has initially little to do with it when the alien is analysing the sunrise if this is a smart alien.

The theoretical analysis, and how well the alien is at it, will determine how the alien will model the situation and how the alien will perform a potential Bayesian analysis.

At the aliens planet the alien doesn't have days but a smart alien (one that understands Bayesian analysis) should, after experiencing day and night on earth, be able to deduce that this circular bright thing that rises into the air is the star which the planet is circling around. And after a single day the alien should know that there is only one single star in the system (unless the observation of the sun's trajectory is made difficult and the alien might belief or consider that there are more than one stars or that the orbit of the planet is unstable which might result in variable daily periods and uncertainty about the sunrise for the next "day").

This is not Bayesian or other statistical analysis but simple deduction and theoretical knowledge of physics that the alien will apply.

The alien could use a Bayesian analysis. After seeing a sunrise and day and night cycle you could test different hypotheses. But the problem with all potential hypotheses is that if they are not the hypothesis 'the planet is rotating around it's axis and has a daily cycle around 24 hours' then

• either the hypothesis does not explain the sunrise and P(sunrise | other theory) is zero
• or they do explain the sunrise but are extremely unlikely theories (e.g. the alien might believe that it is a dream or very weird space ship).

For such kind of hypotheses the alien won't be able to do a formal Bayesian analysis because the prior probabilities and the likelihood are not able to be determined with a reasonable accuracy.

However, since most of those probabilities are incredibly small the alien won't need to use a formal analysis. After seeing a sunrise and day and night cycle the alien will believe that the planet has a daily cycle and will strongly believe that there is a sunrise every 24 hours. The alien won't be able to express exactly the probability since the prior probabilities are not able to be expressed, but the alien will know that the posterior probability is very close to 100%.

Probability of seeing sun rise tomorrow using Bayes Theorem

Bayes theorem is used to describe probabilities of different hypotheses/theories.

The probability of events is not directly modeled with Bayes theorem, but given the posterior probability of the hypotheses/theories, you can compute a posterior prediction of new events.

You seem to be making a shortcut here and in your formula...

P(belief | observation) = P(observation | belief) x P(belief) / P(observation)

... you are filling in the observation 'sunrise' as the hypothesis/belief.

Why does the posterior probability go beyond 1? What am I doing wrong here?

The term P(observation) is filled in based on observational data, but it should be computed as

P(observation) = P(observation | belief)*P(belief) + P(observation | not belief)*P(not belief)

### About the sun example in Price's and Bayes' work.

The problem statement is as following

Let us imagine to ourselves the case of a person just brought forth into this world, and left to collect from his observation of the order and course of events what powers and causes take place in it. The Sun would, probably, be the first object that would engage his attention; but after losing it the first night he would be entirely ignorant whether he should ever see it again. He would therefore be in the condition of a person making a first experiment about an event entirely unknown to him. But let him see a second appearance or one return of the Sun, and an expectation would be raised in him of a second return, and he might know that there was an odds of 3 to 1 for some probability of this. This odds would increase, as before represented, with the number of returns to which he was witness. But no finite number of returns would be sufficient to produce absolute or physical certainty. For let it be supposed that he has seen it return at regular and stated intervals a million of times. The conclusions this would warrant would be such as follow. There would be the odds of the millioneth power of 2, to one, that it was likely that it would return again at the end of the usual interval. There would be the probability expressed by 0-5352, that the odds for this was not greater than 1,600,000 to 1; and the probability expressed by 0-5105, that it was not less than 1,400,000 to 1.

The used model here is that the sun rises every 24 hours with some probability $$p$$ (as if it is a coin flip or other random event) and we ask ourselves what is $$p$$?

One solution to that specific setting is to use a 1,1 beta prior for the parameter $$p$$ (which is equal to a uniform distribution) and update the posterior based on the observations whether or not the sun rises a particular period of 24 hours.

Then the posterior is a 1,1+k beta distribution if we (and the history book) have observed $$k$$ days without the sun not rising. The average of this distribution is (k+1)/(k+2) making an estimate for the odds of a sunrise 1 to k+1.

This example problem is a bit difficult. We need to imagine ourselves a person that is unaware of the mechanics of the sun and models this as if it is an object that has some probability to appear every day.

In the problem setting of this stackexchange question it is made even more difficult. We need to imagine an alien and how it would model the situation. Also it is unclear what we need to do with the information about the thunder and the sky changing colours and how to incorporate the data that no sunrise was seen. It becomes unclear what we are actually modelling, the probability that we see a sunrise (e.g. including the chance that we oversleep and remain in our cave an entire day without seeing the sun) or the probability that there is a sunrise?

It is not for nothing that Price and Bayes wrote the following a paragraph after their sun example

It should be carefully remembered that these deductions suppose a previous total ignorance of nature. After having observed for some time the course of events it would be found that the operations of nature are in general regular, and that the powers and laws which prevail in it are stable and permanent. The consideration of this will cause one or a few experiments often to produce a much stronger expectation of success in further experiments than would otherwise have been reasonable; just as the frequent observation that things of a sort are disposed together in any place would lead us to conclude, upon discovering there any object of a particular sort, that there are laid up with it many others of the same sort. It is obvious that this, so far from contradicting the foregoing deductions, is only one particular case to which they are to be applied.

These potential considerations make the problem statement unclear. The question could be better stated as 'probability of seeing a sun rise tomorrow by naively applying the law of succession'.

In reality, this is not how this problem will be tackled by the alien. The problem of a sunrise tomorrow is not to be based on previous observations of a sunrise, because the model of a sunrise on a particular day as an independent Bernoulli trial is a wrong* model. The sun is not like the mailman who might have a day of being sick. If the sun doesn't rise tomorrow then it is because of some catastrophic event.

*Yes, all models are wrong. But this Bernoulli trial model for the sunrise is very unuseful (as far as we can describe 'usefulness' in this setting, another problem with this example).

• Thanks for your answer. "Bayes theorem is used to describe probabilities of different hypotheses/theories. The probability of events is not directly modeled with Bayes theorem" this statement was really helpful. Thanks! "you are filling in the observation 'sunrise' as the hypothesis/belief." - But "sunrise" is a hypothesis, while sky changing colors is an "observation". Bayes theorem helps in telling P(hypothesis | observation) and so how is that a short cut? Commented Jun 4, 2022 at 21:49
• Regarding hypothesis, I think that's the reason many learning examples are "balls and urn" types. In those situations it's much easier to make sensible hypothesis like "I chose urn 3" and observations like "The two balls I drew were red". Commented Jun 4, 2022 at 21:50
• Finally, yes P(observation) should be broken down into the addition of its occurrences when the hypothesis is true and when false, but why is that different from P(observation) = (#of instances when the given observation was recorded / #total number of instances)? After all that is how we compute probabilities. In theory, both methods should give the same probability. Commented Jun 4, 2022 at 21:51
• @Batool, "sunrise" isn't a hypothesis, it's an event, an observation. Just the same as the sky changing color. Seeing a sunrise is like rolling a 6 on a die. A hypothesis would be more like "the probability of seeing a sunrise is twice as high if the sky changes color". Commented Jun 4, 2022 at 21:53
• You get into troubles with that practice and mixing up terms and not clearly defining or deriving probabilities and likelihoods. Eventually you get the error because on the one hand you compute that P(observation) = 5/10 and on the other hand you compute P(observation and belief) = 4/5*0.74, which is larger. But the P(observation) that you computed is not P(observation) it is just the observed frequency, it is a sample and not the underlying distribution. Commented Jun 4, 2022 at 22:17