11

Minecraft time is measured in ticks. When a world is loaded, the game waits anywhere from 12,000 to 180,000 ticks to start raining. After it starts raining, the rain lasts anywhere from 12,000 to 24,000 ticks. When the rain ends, clear weather lasts for another 12,000 to 180,000 ticks, etc. This cycle repeats forever.

I want to know if there is a function that can determine the chance that it's raining on tick t.

From ticks 0 to 12,000 the chance is 0%.

From ticks 12,000 to 24,000 the chance is (t - 12,000) / 168,000 (I believe)

After this, I got confused. What would the probabilities be past this point? I created a simulation to brute force it and this is what the graph looked like

enter image description here

(x is ticks in thousands, y is the percentage chance of rain).

But I'm not actually sure what the function for this would be.

Thank you.

Amir
  • 4,305
  • Do I understand correctly that the clear period is uniformly distributed between $12,000$ and $180,000$ ticks? That is, each duration has probability $1/168,000$ probability of being chosen? And similarly for the rainy period? – Brian Tung Feb 23 '24 at 17:18
  • @BrianTung that's correct – Benjamin Gilbert Feb 23 '24 at 18:50

2 Answers2

8

Let $C_i\sim C$ and $R_i \sim R$ denote the durations (in ticks) of the $i$th coupled periods of clear and rainy weathers, respectively. We want to find

$$p(t)=\mathbb P \left (A_t:=\text{at time $t$ the weather is $\bf{rainy}$} \right ).$$

Let us define $$q(t)=1- p(t)=\mathbb P \left (A'_t:=\text{at time $t$ the weather is $\bf{clear}$} \right ).$$

By conditioning on $C_1$, we have

$$q(t)=\mathbb P (A'_t \, |C_1>t)\mathbb P (C_1>t)+\mathbb P (A'_t, C_1 \le t).$$

By observing

$$\mathbb P (A'_t \, |C_1>t)=1$$

$$\mathbb P (A'_t, C_1 \le t)=\int_{0}^{\infty} \mathbb P (A'_t, C_1 \le t|R_1+C_1=x) \text{d}F_{R_1+C_1}(x)= \int_{0}^{t} q(t-x) \text{d}F_{R_1+C_1}(x),$$

we obtain

$$\color{blue}{p(t)=1- q(t) \\ q(t)=1-F_{C}(t)+\int_{0}^{t} q(t-x) \text{d}F_{R+C}(x).}$$

When $F_{R+C}$ has a pdf, denoted by $f_{R+C}$, it is a linear Volterra integral equation, which can be solved by Laplace transformation. The final solution is

$$\color{blue}{p(t)= 1-\mathcal L^{-1} \left [\frac{\mathcal L[1-F_{C}](s)}{1-\mathcal L[f_{R+C}](s)} \right ](t)}.$$

For $C \sim \alpha+U(0,a)$ and $R\sim \alpha + U(0,b)$ with $\alpha=12000, a=168000 , b=12000$, from the above you can find $p(t)$ by considering that ($a>b$)

$$F_{C}(t)=\min \left(1,\frac{t-\alpha}{a} \right )I_{(\alpha,\infty)}(t)$$ $$f_{R+C}(x)=\frac{1}{ab}(x-2\alpha)I_{(2\alpha,2\alpha+b)}(x)+\frac{1}{a}I_{(2\alpha+b,2\alpha+a)}(x)+\left (\frac{1}{a}-\frac{1}{ab}(x-2\alpha-a) \right )I_{(2\alpha +a,2\alpha + a + b)}(x).$$

After determining $\mathcal L[1-F_{C}]$ and $\mathcal L[f_{R+C}](s)$, see here and here, the above gives (for presentation simplicity to obtain the following, the time unit is in thousands of ticks):

$$1-\mathcal L^{-1} \left [\frac{\frac{e^{-180 s} - e^{-12 s} + 168 s}{168 s^2}}{1 - \frac{e^{-204 s} (1 - e^{12 s} - e^{168 s} + e^{180 s})}{2016 s^2}} \right ](t).$$

The inner of the inverse Laplace transform can be simplified as

$$\frac{12 e^{24 s} (1 - e^{168 s} + 168 e^{180 s} s)}{ e^{12 s} + e^{168 s} - e^{180 s} + 2016 e^{204 s} s^2-1}.$$

After checking many options, it seems there is no closed-form expression for this function. WolframAlpha could not obtain the inverse Laplace transform, see here. Also, Mathematica could not find any closed-form solution.

Finally, I asked some experts to help in this Wolfram question. Fortunately, we can find the inverse numerically. I used the final result obtained by Mariusz Iwaniuk based on the GWR method in a reply to my question among different methods, which seems to be more reliable (for more details, codes, etc. see that question). Thus, the final solution for $p(t)$ can be depicted as follows:

Probability of Raining over Time


Limiting case:

As $q(t)$ is a solution for

$$p(t)=1-F_{C}(t)+\int_{0}^{t} p(t-x) \text{d}F_{R+C}(x),$$

from here, it can be expressed as

$$q(t)=1-F_{C}(t)+\int_{0}^{t} (1- F_{C}(t-x))\text{d}m(x)$$

where $m(t)$ is the mean of the number of renewals by time $t$ in a renewal process in which the distribution of the inter-arrival times follows $R+C$. From the above we can see that

$$\lim_{t \to \infty}q(t)=\lim_{t \to \infty}(1-F_{C}(t))+\lim_{t \to \infty}\int_{0}^{t} (1- F_{C}(t-x))\text{d}m(x)=0+\frac{1}{\mathbb E (R+C)}\int_{0}^{\infty} (1- F_{C}(x))\text{d}x=\frac{\mathbb E (C)}{\mathbb E (R)+\mathbb E (C)}. \tag{2}$$

Thus,

$$\color{blue}{\lim_{t \to \infty}p(t)}=1-\lim_{t \to \infty}q(t)= \color{blue}{\frac{\mathbb E (R)}{\mathbb E (R)+\mathbb E (C)}}=\frac{\frac{12000+24000}{2}}{\frac{12000+180000}{2}+\frac{12000+24000}{2}}=\color{blue}{\frac{3}{19}}.$$

The last limit in (2) is obtained from the key renewal theorem:

$$\lim_{t \to \infty} \int_{0}^{t} g(t-x)\text{d}m(x)=\frac{1}{\mu}\int_{0}^{\infty} g(x)\text{d}x,$$

which holds for any non-decreasing function $g: \mathbb R_{\ge0} \to \mathbb R_{\ge0}$ with finite $\int_{0}^{\infty} g(x)\text{d}x$ whenever the distribution of the interval arrivals in the renewal process with $m(x)$ is non-lattice and has the finite mean $\mu$.

Amir
  • 4,305
3

You can forget about the first $12000$ ticks. Let $W_i$ and $R_i$ be the duration of the $i-$th clear weather and the $i-$th rain, then $$W_i \sim U(12000, 180000) \quad \text{and} \quad R_i \sim U(12000, 24000)$$

The probability that you are looking for is $$\mathbb P\left[\bigcup_{n\in \mathbb N}\left\{\sum_{i=1}^{n} W_i + \sum_{i=1}^{n-1} R_i\le t < \sum_{i=1}^{n} W_i + \sum_{i=1}^{n} R_i\right\}\right] = \sum_{n=1}^{\infty} \mathbb P\left[\left\{\sum_{i=1}^{n} W_i + \sum_{i=1}^{n-1} R_i\le t < \sum_{i=1}^{n} W_i + \sum_{i=1}^{n} R_i\right\}\right]$$

and I don't think you can find a closed form of this. If $t$ is large may be using a CLT approximation can help.

Kroki
  • 13,135