# "Piecewise" in "ProbabilityDistribution" would not affect the result

D[Probability[Sin[X] < y,
Distributed[X,
ProbabilityDistribution[
Piecewise[{{2*x/(Pi^2), 0 < x < Pi}, {0,
x <= 0 || x >= Pi}}], {x, -Infinity, Infinity}]]],
y] // Simplify


produces $$\left\{\begin{array}{cc} & \begin{array}{cc} \frac{2}{\pi \sqrt{1-y^2}} & 01\lor y<0 \\ \text{Indeterminate} & \text{True} \\ \end{array} \\ \end{array}\right.$$

However,

D[Probability[Sin[X] < y,
Distributed[X,
ProbabilityDistribution[
Piecewise[{{2*x/(Pi^2), 0 < x < Pi}}], {x, -Infinity,
Infinity}]]], y] // Simplify


produces the same result. I guess in the first example, the Piecewise doesn't work. In the first example, the right answer should be

$$\left\{\begin{array}{cc} & \begin{array}{cc} \frac{2}{\pi \sqrt{1-y^2}} & 0

• Since the default for Piecewise is the value zero, the two Piecewise statements are equivalent, i.e., "Piecewise[{{2*x/(Pi^2), 0 < x < Pi}, {0, x <= 0 || x >= Pi}}] === Piecewise[{{2*x/(Pi^2), 0 < x < Pi}}] evaluates to True Commented Jan 20 at 15:08
• @BobHanlon: Did you pay your attention to my answer submitted before your comment? Commented Jan 20 at 15:34
• @user64494 I think his/her comment is imortant here, but as there is one condition applied, so the default value for Piecewise shouldn't work here. Why does the default value zero does work in this situation? Commented Jan 21 at 3:18

Mathematica is right in both cases, you are not. First,

FullSimplify[ Piecewise[{{2*x/(Pi^2), 0 < x < Pi}, {0, x <= 0 || x >= Pi}}]-
Piecewise[{{2*x/(Pi^2), 0 < x < Pi}}]]


0

and this explains the identical results (also look in the documentation to Piecewise for info). Second,

Probability[Sin[X] < y,  Distributed[X,  ProbabilityDistribution[
Piecewise[{{2*x/(Pi^2), 0 < x < Pi}, {0,  x <= 0 || x >= Pi}}], {x, -Infinity, Infinity}]]]


Piecewise[{{1, y > 1}, {(2*ArcSin[y])/Pi, Inequality[0, Less, y, LessEqual, 1]}}, 0]

and the plot

Plot[Piecewise[{{1, y > 1}, {(2*ArcSin[y])/Pi,
Inequality[0, Less, y, LessEqual, 1]}}, 0], {y, -1, 2},
WorkingPrecision -> MachinePrecision, PlotPoints -> 200]


clearly shows its non-differentiability at y==0 and y==1` (rigorous proof on demand).