Premium problem66. Distance Between Two Uniforms

Medium Locked

Let XX and YY be independent Uniform(0,1)\mathrm{Uniform}(0,1). Return P(low≤∣X−Y∣≤high)P(\text{low} \leq |X - Y| \leq \text{high}).

The distance has a known cumulative distribution, which you can read off the unit square as the area outside two corner triangles:

P(∣X−Y∣≤t)=2t−t2P(|X-Y| \leq t) = 2t - t^2

Input

low = 0.0
high = 0.5

Output

0.75

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)