Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #11940 > unrolled thread

Re: Get Distribution from Interpolated Function

Started byBob Hanlon <hanlonr357@gmail.com>
First post2012-10-04 03:39 +0000
Last post2012-10-04 03:39 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Get Distribution from Interpolated Function Bob Hanlon <hanlonr357@gmail.com> - 2012-10-04 03:39 +0000

#11940 — Re: Get Distribution from Interpolated Function

FromBob Hanlon <hanlonr357@gmail.com>
Date2012-10-04 03:39 +0000
SubjectRe: Get Distribution from Interpolated Function
Message-ID<k4j0dn$7ml$1@smc.vnet.net>
ff = Interpolation[
   Table[{i, 1 + RandomReal[]},
    {i, 0, 10}]];

Using the option Method->"Spline" is incompatible with the functions below.

The first argument to ProbabilityDistribution should be a PDF, i.e.,
it must be normalized.

dist = ProbabilityDistribution[ff[x]/Integrate[ff[x], {x, 0, 10}],
   {x, 0, 10}];

randomData = RandomVariate[dist, 100000];

Show[
 Histogram[randomData, {0.1}, "PDF",
  ChartBaseStyle -> EdgeForm[None]],
 Plot[PDF[dist, x], {x, 0, 10},
  PlotStyle -> {Red, AbsoluteThickness[2]}]]


Bob Hanlon


On Wed, Oct 3, 2012 at 3:09 AM, Murta <rodrigomurtax@gmail.com> wrote:
> Hi All
>
>     I'm trying to get a distribution from an interpolated function but with no success.
>
> (*Creating Dist from interpolation*)
> ff = Interpolation[Table[{i, 1 + RandomReal[1]}, {i, 0, 10, 1}], Method -> "Spline"];
> dist = ProbabilityDistribution[ff[x], {x, 0, 10}];
>
>  (*Plot Interpolation ok!*)
> Plot[ff[x], {x, 0, 10}]
>
> (*Plot Dist ok!*)
> Plot[Evaluate@PDF[dist, x], {x, 0, 10}]
>
> (*do not work as spected, the histogram don't have the curve format*)
> randonData = RandomVariate[dist, 100000];
> Histogram[randonData, {0.1}, "Probability",  PlotRange -> {{0, 10}, All}]
>
> tks in advance
> Murta
>

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web