Message Boards Message Boards

0
|
397 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Slow Probability Density Function and Slow Density Plot

Posted 14 days ago

I am doing some work with Random Variables and Probability Density Functions. I have entered the following commands:

\[ScriptCapitalD] = TransformedDistribution[Abs[a - b] + Abs[u - v], 
                             {a \[Distributed] UniformDistribution[],
                              b \[Distributed] UniformDistribution[],                                                                      
                              u \[Distributed] UniformDistribution[],
                              v \[Distributed] UniformDistribution[]}]

PDF[\[ScriptCapitalD], x]

Everything works as it should, albeit slowly. When I ask for the plot via

Plot[PDF[\[ScriptCapitalD], x], {x, -2, 4}, Filling -> Axis]

things get super slow.
Does anyone know what I am doing wrong?

POSTED BY: Patrick McMullen
2 Replies
Posted 14 days ago

I don't know what you mean by "slow". The following works after about 60 seconds:

dist = TransformedDistribution[Abs[a - b] + Abs[u - v],
   {a \[Distributed] UniformDistribution[], 
    b \[Distributed] UniformDistribution[],
    u \[Distributed] UniformDistribution[], 
    v \[Distributed] UniformDistribution[]}];
Plot[Evaluate[PDF[dist, x]], {x, -2, 4}, Exclusions -> None, ImageSize -> Large]

pdf

POSTED BY: Jim Baldwin

Thank you, Jim. The Evaluation[] function inside the Plot[] function seems to have made the difference. I was not aware of this function, but now things work.

Prior to this, I was waiting hours for the plot.

POSTED BY: Patrick McMullen
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