*co-written with Aditya Deshmukh*

It is generally considered courteous for men to put the toilet seat down after they pee in a mixed-gender shared bathroom. Is this really optimal strategy, though? What does optimal even mean?

## Defining the problem

We make a few assumptions to model the problem: men always pee standing up, and need the toilet seat up to do so. Women pee sitting down, and both men and women poop sitting down, requiring the seat to be down in each of these scenarios. Touching the toilet seat is generally unpleasant and hence we consider the problem of minimizing the number of times people need to flip the toilet seat (i.e. change its position) . While a myriad complicated strategies are possible, a few jump out:

**Gentleman**: Always leave the seat down after you’re done**Gentlewoman**: Always leave the seat*up*after you’re done**Lazy**: Leave the seat as you last used it

## Analysis through simulation

To gain an intuition for the problem at hand, we built a simple toilet simulator that allows one to tweak some parameters and see how they affect outcomes.

In a household with an equal number of men and women, the *gentleman*
strategy requires a number of flips roughly equal to the number of time the toilet is used (or a 1x
flip factor) — women never need to flip a seat, while men must first put the
seat up when they pee then put it back down once they’re done. The *gentlewoman*
strategy does similarly, with the women doing most of the
flipping (flip factor ~1x again), though it results in a greater total number of
flips, since men must also do 2 flips every time they go poo. The *lazy*
strategy really shines in comparision, though. With a flip factor of 0.5x, it
only requires half the number of flips as the number of times the toilet gets
used. Half the flips are done by women and half by men.

Households with a higher proportion of men make the gentleman strategy perform
worse — a 1.5x flip factor at 80/20 man/woman split; and the gentlewoman
strategy perform better — 0.6x flip factor at 80/20. Once again *lazy*
outperforms, with a 0.4x flip factor.

So far, the result matches our intuition — flipping the toilet seat after using it in anticipation of future use would get “wasted” if the subsequent use isn’t what you were expecting it to be.

## More rigour, using Markov Decision Processes

There could, however, be a less obvious more complicated strategy that beats
*lazy*. To figure this out, we model this problem as a **Markov Decision
Process**. The initial position of the seat, the person’s gender, and whether
the person wants to pee or poop is encoded in the state. The state space, then,
looks like:

The choice of which position to leave the seat in encoded as an action. The action space looks like:

\[\mathcal{A} = \{U,D\}\]We asssume random bathroom usage by gender, and assign the probabilities of the next bathroom usage to be independent of the current state, or the previous usage.

The cost of visiting a state and taking an action is set as the number times one has to flip the toilet seat.

State | Action | Cost | State | Action | Cost |
---|---|---|---|---|---|

\((👨🏻,💦,U)\) | \(U\) | \(0\) | \((👨🏻,💦,U)\) | \(D\) | \(1\) |

\((👨🏻,💦,D)\) | \(U\) | \(1\) | \((👨🏻,💦,D)\) | \(D\) | \(2\) |

\((👨🏻,💩,U)\) | \(U\) | \(2\) | \((👨🏻,💩,U)\) | \(D\) | \(1\) |

\((👨🏻,💩,D)\) | \(U\) | \(1\) | \((👨🏻,💩,D)\) | \(D\) | \(0\) |

\((💃,💦,U)\) | \(U\) | \(2\) | \((💃,💦,U)\) | \(D\) | \(1\) |

\((💃,💦,D)\) | \(U\) | \(1\) | \((💃,💦,D)\) | \(D\) | \(0\) |

\((💃,💩,U)\) | \(U\) | \(2\) | \((💃,💩,U)\) | \(D\) | \(1\) |

\((💃,💩,D)\) | \(U\) | \(1\) | \((💃,💩,D)\) | \(D\) | \(0\) |

We consider an infinite-horizon MDP and solve for the optimal stationary policies which minimize the limiting average cost.

\[% \pi_1^*=\min_{\pi}\mathsf{E}_{\pi}\left[\sum\limits_{t=0}^\infty \beta^t c(S_t,A_t)|S_0=s_0 \right]\\ \pi^*=\min_{\pi}\mathsf{E}_{\pi}\left[ \lim_{T\to\infty}\frac{1}{T}\left[\sum\limits_{t=0}^Tc(S_t,A_t)|S_0=s_0 \right]\right]\]Solving this MDP problem, **the optimal strategy turns out to be the lazy
strategy.** Another interesting finding is that the lazy strategy is optimal for
any proportion of men and women in the household, and irrespective of how
frequently each gender pees or poops. This matches our intuition as well as the empirical
result that we got using simulation above.

## Are the cost functions fair?

Our analysis so far assumes that the cost of having to flip a seat is identical
for men and women. This is not necesssarily true — e.g. if a man finds a seat
down and pees without putting it up, he has to deal with a dirty seat to clean.
A woman in the opposite scenario, though, risks having her bum touch toilet
water, or even worse falling into the toilet. We model this assymetry by
adjusting the cost function in our MDP. If we model the cost to flip for a woman
as twice the cost to flip for a man in our MDP above — e.g. \((💃,💦,U) = 2\)
instead of \(1\); we see the *gentleman* strategy
finally outperform *lazy* provided that at least ⅔ of the people living in the
house are women. For a higher cost-differential, the proportion of
the household needing to be women for the gentleman strategy to be optimal
naturally drops.

## In Conclusion

While the cost function will vary with every household, this analysis
provides a framework to think through an optimal strategy for you. The *lazy*
strategy is best if minimizing flips is the only concern. Consider adopting the
*gentleman* strategy in a household with a higher proportion of women, or
when the cost of getting it wrong is particularly high — say going to pee in
the middle of the night when the dark and your groggy brain make falling into
the toilet more likely.