3
$\begingroup$
PDF[TransformedDistribution[Sin[X], 
   Distributed[X, ProbabilityDistribution[2*x/(Pi^2), {x, 0, Pi}]]], 
  y] // Simplify

produces

PDF[TransformedDistribution[Sin[X], 
  X \[Distributed] 
   ProbabilityDistribution[(
    2 \[FormalX])/\[Pi]^2, {\[FormalX], 0, \[Pi]}]], y]

enter image description here

But

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

can produce $$\left\{\eqalign{&0,\,&y<0\cr &\frac{2}{\pi\sqrt{1-y^2}},\,0<&y<1\cr &0,\,&y>1\cr &{\rm Indeterminate,}\,&{\rm True} }\right.$$ enter image description here

Why doesn't TransformedDistribution work but finding the probability first and then the derivative can give the right result?

$\endgroup$
6
  • 2
    $\begingroup$ I wish I knew the answer. Note that using Sin[X] <= y rather than Sin[X] < y just returns the Mathematica code. Sometimes using a distribution in Mathematica's repertoire works. But using the equivalent PowerDistribution[1/Pi, 2] doesn't work either. $\endgroup$
    – JimB
    Commented Jan 20 at 19:14
  • $\begingroup$ @JimB So, there is a bug that {x, a, b} always means $a\le x\le b$, so users can't make a $a<x<b$ by {x, a, b} style. $\endgroup$
    – Y. zeng
    Commented Jan 21 at 5:02
  • $\begingroup$ A desired feature not implemented is not a bug. But writing to Wolfram, Inc. with the issue would seem to be the next step (unless someone else here has other suggestions). At least in this case you have a workaround. $\endgroup$
    – JimB
    Commented Jan 21 at 6:18
  • $\begingroup$ @JimB But now, I think it isn't what as you said. Try PDF[TransformedDistribution[Sin[X], Distributed[X, ProbabilityDistribution[2*x/(Pi^2), {0.1, 0, 0.99*Pi}]]], y] // Simplify will return the code too. $\endgroup$
    – Y. zeng
    Commented Jan 21 at 6:22
  • $\begingroup$ It's too late at night for me as I'm not seeing how your example contradicts anything I've written. $\endgroup$
    – JimB
    Commented Jan 21 at 6:30

1 Answer 1

1
$\begingroup$

This is not an answer to your question but rather another alternative to use when TransformedDistribution doesn't work.

The pdf of $X$ is

pdfx[x_] := Piecewise[{{2 x/π^2, 0 <= x <= π}}]

The desired transformation ($Y=\sin(X)$) is not a 1-to-1 transformation (as for every $Y$ value there are two $X$ values) but is 1-to-1 in two separate segments. First we find the inverse functions for each of the two segments (meaning $0\leq X < \pi/2$ and $\pi/2 \leq X \leq \pi$).

sol1 = Simplify[x /. Solve[{Sin[x] == y, 0 <= x < π/2}, x][[1]], Assumptions -> 0 < y < 1]
(* ArcSin[y] *)
sol2 = Simplify[x /. Solve[{Sin[x] == y, π/2 <= x < π}, x][[1]], Assumptions -> 0 < y < 1]
(* π - ArcSin[y] *)

Now we construct the pdf for $Y=\sin(X)$:

pdfy = Simplify[pdfx[sol1] Abs[D[sol1, y]] + pdfx[sol2] Abs[D[sol2, y]] // PiecewiseExpand,
  Assumptions -> 0 <= y <= 1]
(* 2/(π Sqrt[1 - y^2]) *)

The following link has more details on this approach: https://online.stat.psu.edu/stat414/book/export/html/772.

$\endgroup$
2
  • $\begingroup$ PDF[TransformedDistribution[Sin[X] + 2 X, Distributed[X, ProbabilityDistribution[2*x/(Pi^2), {x, 0, Pi}]]], y] // Simplify does not work too, though Sin[X]+2X is one-to-one map. $\endgroup$
    – user64494
    Commented Jan 23 at 18:41
  • $\begingroup$ @user64494 I made no claim that TransformedDistribution should work if the there was a one-to-one map. For example, Cos[X] is a one-to-one map for $0<X<\pi$ but it doesn't work either. $\endgroup$
    – JimB
    Commented Jan 23 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.