Message Boards Message Boards

0
|
4727 Views
|
17 Replies
|
6 Total Likes
View groups...
Share
Share this post:

How to calculate the probability density of Y=X^3 based on another probability density function?

Posted 6 months ago

Hello,

How to calculate this in Mathematica?

Suppose the probability density of random variable X is f(x), −∞<x<∞. what is the probability density of Y=X^3?

POSTED BY: Zhenyu Zeng
17 Replies
Posted 6 months ago

Okay. Thanks for your kind comfirmation.

Regards

POSTED BY: Zhenyu Zeng
Posted 6 months ago

Hello,

Thanks for your kind reply and sorry for my delay reply. I have checked the document again. Now, I kne w the default 0 value for val. Before I had misunderstood it. So, there is no quesion now.

Best regards,

POSTED BY: Zhenyu Zeng

Yes, it is sad that this does not work

PDF[TransformedDistribution[Sin[X], 
  X \[Distributed] 
   ProbabilityDistribution[2*x/(Pi^2), {x, 0, \[Pi]}]], y]
POSTED BY: Gianluca Gorni

Sorry, I don't understand your question. "As the Subscript[cond, i] applies, such as 0 < x < Pi": the condition applies to what?

POSTED BY: Gianluca Gorni
Posted 6 months ago

Thanks.

Piecewise uses default value val if none of the Subscript[cond, i] apply. The default for val is 0.

As the Subscript[cond, i] applies, such as 0 < x < Pi, so the default for val is not used here. They should not be the same.

POSTED BY: Zhenyu Zeng
Posted 6 months ago

Thanks.

But this one doesn't work either.

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

As it produces

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

The density of a probability distribution is an object that is meant to be integrated on intervals. Its value in a single point does not matter at all for the distribution. In advanced calculus we call it a function defined almost everywhere.

The default value of Piecewise is zero. Hence the two functions

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

are the same thing.

POSTED BY: Gianluca Gorni

Beware the syntax:

Probability[Sin[X] < t, 
 X \[Distributed] ProbabilityDistribution[2*x/(Pi^2), {x, 0, Pi}]]
D[%, t]
POSTED BY: Gianluca Gorni
Posted 6 months ago

Hello,

Why doesn't this one work:

PDF[TransformedDistribution[Sin[X], 
  X \[Distributed] ProbabilityDistribution[2*x/(Pi^2), 0 < x < Pi]],
  y]

This one produces the

PDF[TransformedDistribution[Sin[X], 
  X \[Distributed] ProbabilityDistribution[2*x/(Pi^2), 0 < x < Pi]],
  y]
POSTED BY: Zhenyu Zeng
Posted 6 months ago

Thanks.

I just feel that it is better to make ProbabilityDistribution function to use the range of Piecewise. For the second quesiton, I have a different view from you. From the original Probability Distribution fuction

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

which has stated that when x=0 or x>=Pi, the Probability Distribution is 0. So, when y=0 and y=1, its Probability Distribution should be 0 too.

May you check this:

The first

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

The second

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

They have the same results. Not weird?

POSTED BY: Zhenyu Zeng

The {x, -Infinity, Infinity} looks redundant but it is required by the syntax of ProbabilityDistribution.

The Piecewise formula is perfectly correct, because it is the answer to the derivative of this function:

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

You can see from the plot that for y == 0 and for y == 1 the function is not differentiable. The derivative from the left and from the right are different.

POSTED BY: Gianluca Gorni
Posted 6 months ago

Thanks.

Do feel it is a little weird as in

ProbabilityDistribution[
 Piecewise[{{1 + x, -1 < x < 1},
   {1/x, 1 < x < 2}}],
 {x, -Infinity, Infinity},
 Method -> "Normalize"]

Outside of the Piecewise, there is {x, -Infinity, Infinity}. As Piecewise have given the range of the function, why should we add {x, -Infinity, Infinity} after it?

Another question:

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

outputs

enter image description here

Do you think this is the right answer? I think in this Piecewies limits, the answer should be

2/(\[Pi] Sqrt[1 - y^2]), 0<y<1  and  0, y equals others.
POSTED BY: Zhenyu Zeng

You could answer yourself by reading the documentation or experimentation. Here is an example of Piecewise probability density:

ProbabilityDistribution[
 Piecewise[{{1 + x, -1 < x < 1},
   {1/x, 1 < x < 2}}],
 {x, -Infinity, Infinity},
 Method -> "Normalize"]

The conditions in Piecewise are to be tested in the given order: the first that gives True is applied. The last condition is always True, and it applies when all the previous tests give False. It is the complement of the other tests. It can be confusing at first.

POSTED BY: Gianluca Gorni
Posted 6 months ago

Thanks a lot.

  1. How to use Piecewise function in ProbabilityDistribution function?
  2. Why is the Indeterminate range is True and what is the meaning of True here?

Regards,

POSTED BY: Zhenyu Zeng

Those #1 are used to express algebraic numbers. You can check the documentation on Root. Actually, in that particular expression we find repeatedly Root[-t + #1^3 &, 1], which is simply the real cubic root of t. You can replace it with Surd[t, 3]:

FullSimplify[
 Root[-t + #1^3 &, 1] == Surd[t, 3],
 Element[t, Reals]]

The Indeterminate appears when y == 0 and when y == 1, where the derivative does not exist. You can plot the density function and see that it is discontinuous in those points:

D[Probability[Sin[X] < y,
   Distributed[X,
    ProbabilityDistribution[2  x/(Pi^2),
     {x, 0, Pi}]]], y] // Simplify
Plot[%, {y, -1, 2}]
POSTED BY: Gianluca Gorni
Posted 6 months ago

Okay. Thanks.

Did you see your results, in which there are many #1. Is it right?

(1/(4 \[Pi]))(2 \[Pi]-2 ArcTan[1-Sqrt[2] Root[-t+#1^3&,1]]+2 ArcTan[1+Sqrt[2] Root[-t+#1^3&,1]]-Log[1-Sqrt[2] Root[-t+#1^3&,1]+Root[-t+#1^3&,1]^2]+Log[1+Sqrt[2] Root[-t+#1^3&,1]+Root[-t+#1^3&,1]^2])

Another question:

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

The output is enter image description here

Why are there Inderterminate here and what is the meaning of that? I think this one should be omitted.

POSTED BY: Zhenyu Zeng

Sadly, it seems that Mathematica cannot handle generic symbolic distributions:

Probability[X > 0,
 Distributed[X,
  ProbabilityDistribution[f[x],
   {x, -Infinity, Infinity}]]]

For an explicit distribution it works:

Probability[X^3 < t,
 Distributed[X,
  ProbabilityDistribution[
   Sqrt[2]/Pi/(1 + x^4),
   {x, -Infinity, Infinity}]]]
D[%, t] // Simplify
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract