[SciPy-user] Another problem with triangular pdf

Robert Kern kern at ugcs.caltech.edu
Wed Oct 22 18:20:15 EDT 2003


On Wed, Oct 22, 2003 at 04:39:06PM -0500, Santiago Erquicia wrote:
> I'm working with the triangular pdf and I find that this is not normalized.
> 
> Given this values of x:
> [ 1.   1.2  1.4  1.6  1.8  2.   2.2  2.4  2.6  2.8  3. ]
> 
> and getting the values of the triangular pdf as follows:
> scipy.stats.triang.pdf(x, distr_shape, loc = distr_location, scale = 
> distr_scale)
> 
> where
> distr_shape = 2.0
> distr_location = 1.0
> distr_scale = 0.5
>
> that represents a triangular distribution with min = 1, mode = 2, and 
> max = 3

Not quite. distr_shape = 0.5; distr_scale = 2.0 is I think what you meant.

> the results are:
> [ 0.   0.2  0.4  0.6  0.8  1.   0.8  0.6  0.4  0.2  0. ]
> 
> Shouldn't the results be always less than 1 

No. All that matters is that the integral between the limits ([loc, loc+scale]
in this case) be 1 and the pdf is always non-negative. In general, the value of
the pdf at any point x has units like 1/x (If x is a random variable in
length, for example, the pdf(x) has units 1/length). Think about if you shrink
the scale factor. To keep the integral equal to 1, the peak must increase.

> and the integral of the pdf 
> from min to x equal to the cdf?

Yes.

The area under the triangle should equal 1. The area under a triangle is
width*height/2 = 2*1/2 = 1 in this case.

The pdf is correct.

-- 
Robert Kern
kern at ugcs.caltech.edu

"In the fields of Hell where the grass grows high
 Are the graves of dreams allowed to die."
                     -- Richard Harter



More information about the SciPy-User mailing list