[Numpy-discussion] Pull request review #3770: Trapezoidal distribution

Jeremy Hetzel jthetzel at gmail.com
Mon Sep 23 13:40:30 EDT 2013


On Sun, Sep 22, 2013 at 9:47 AM, Mark Szepieniec <mszepien at gmail.com> wrote:

>
> On Sun, Sep 22, 2013 at 1:24 PM, <josef.pktd at gmail.com> wrote:
>
>>
>>  I don't see a reason that numpy.random shouldn't get new
>> distributions. It would also be useful to add the corresponding
>> distribution to scipy.stats.
>>
>
I have the pdf, cdf, and inverse cdf for the generalized trapezoidal. I've
looked through the other distributions at scipy.stats and adding this one
should not be difficult. I'll work on it next.


>
>> naming: n, m would indicate to me that they are integers, but it they
>> can be floats (>0)
>> alpha, beta ?
>>
>
The three additional parameters for growth rate, decay rate, and boundary
ratio are floats > 0. I renamed them from `m`, `n`, and `alpha` (which is
how they're parameterized in the published probability density function) to
simply `growth`, `decay`, and `ratio`.  Does that fit into the NumPy style?
It feels intuitive to me.

>

>
>> Is there a standard version, e.g. left=0, right=1, mode1=?, ... ?
>>
>> In scipy.stats.distribution we are required to use a location, scale
>> parameterization, where loc shifts the distribution and scale
>> stretches it.
>> Is there a standard parameterization for that?, for example
>> left = loc = 0 (default)     or left = loc / scale = 0
>> right = scale = 1 (default)
>> mode1_relative = mode1 / scale
>> mode2_relative = mode2 / scale
>> n, m unchanged     no defaults
>>
>> just checked:
>> your naming corresponds to triangular, and triang in scipy has the
>> corresponding loc-scale parameterization.
>>
>
Thanks. There is no standard version of the distribution that I'm aware of,
but for the purposes of scipy.stats, left=0, right=1 and mode1, mode2 being
either 0.25, 0.75 or 1/3, 2/3, seem reasonable. I'll give more thought to
the location and scale and send an email to scipy-dev if I need guidance.
Looking at scipy.stats.triang, my initial thought is:
left_relative = loc
mode1_relative = loc + mode1*scale
mode2_relative = loc + mode2*scale
right_relative = loc + scale
growth, decay, and ratio are unchanged.


>
> I think you need to s/first/second in the description of the mode2
> parameter?
>

Thanks for catching that. Fixed in a recent commit. mode2 should be the
second peak of the distribution.


Jeremy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130923/57c81481/attachment.html>


More information about the NumPy-Discussion mailing list