3
$\begingroup$

I use the RandomFunction to generate a continuous random function (trying to model a rough surface):

r = RandomFunction[WienerProcess[0, 1], {0, 10, 0.01}];
ListLinePlot[r, Filling -> Axis, AxesOrigin -> {0, 0}]

enter image description here

I'm able to plot the histogram by:

Histogram[r, 0.2]

enter image description here

But when I try to make a CDF of the data it is empty:

s = CDF[r, x];
Plot[s, {x, -10, 10}, Filling -> Axis]

I would appreciate if you could help me know what is the problem and how I can solve it.

$\endgroup$
4
  • 2
    $\begingroup$ Maybe s = CDF[EmpiricalDistribution[r], x]; ? $\endgroup$ Mar 13, 2018 at 10:13
  • 1
    $\begingroup$ @kglr It seems EmpiricalDistribution immediately deals with the TemporalData in a sensible fashion. $\endgroup$
    – gwr
    Mar 13, 2018 at 10:19
  • $\begingroup$ @b.gatessucks this actually worked fine $\endgroup$
    – Foad
    Mar 13, 2018 at 10:24
  • 2
    $\begingroup$ @gwr, right. But, in version 9, you need to use EmpiricalDistribution[r["States][[1]]] $\endgroup$
    – kglr
    Mar 13, 2018 at 10:33

1 Answer 1

3
$\begingroup$

If what you want is a cumulative distribution function then you will have to make your run data a distribution. You may use EmpiricalDistribution or SmoothKernelDistribution:

SeedRandom = ["March 13, 2018"];
r = RandomFunction[WienerProcess[0, 1], {0, 10, 0.01}];

dist = EmpiricalDistribution @ r;
Plot[ Evaluate@CDF[ dist, x], {x, -10, 10}, 
    Filling -> Axis, 
    PlotRange -> All, PlotPoints -> 1000
]

CDF

$\endgroup$
4
  • $\begingroup$ I get this error Syntax::sntxf: "SeedRandom=" cannot be followed by "[March 13, 2018]". ! $\endgroup$
    – Foad
    Mar 13, 2018 at 10:20
  • $\begingroup$ I think I did :) I will try again. $\endgroup$
    – Foad
    Mar 13, 2018 at 10:22
  • $\begingroup$ If I may ask a side question? How can I integrate over dist now? e.g. f(x)=int[dist,{u,-5,x}] $\endgroup$
    – Foad
    Mar 13, 2018 at 10:39
  • 2
    $\begingroup$ @Foad But, that should be exactly what CDF[ dist, x ] will do. Manually you could integrate using PDF[ dist, x] or you could use Probability. $\endgroup$
    – gwr
    Mar 13, 2018 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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