[Numpy-discussion] Pull request review #3770: Trapezoidal distribution
josef.pktd at gmail.com
josef.pktd at gmail.com
Tue Sep 24 08:34:21 EDT 2013
On Mon, Sep 23, 2013 at 1:40 PM, Jeremy Hetzel <jthetzel at gmail.com> wrote:
> 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.
`growth`, `decay`, and `ratio` sounds much better
we try also in scipy.stats to move away from some of the one letter
>>> 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.
mode1 and mode2 don't need a default, they can be shape parameters
which don't have defaults in scipy.stats.
with left=0, right=1 hard coded in the formulas, we have a "standard"
version and get the transformation with loc and scale
The implied parameterization looks good,
mode1, mode2 are "relative" to right - left, based on 0,1 interval
(in fractions of left - right length)
your `xxx_relative` are the actual values on the real line, i.e. not
relative to loc and scale
(It's actually the same as with triang, which I had forgotten to look
>> I think you need to s/first/second in the description of the mode2
> Thanks for catching that. Fixed in a recent commit. mode2 should be the
> second peak of the distribution.
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
More information about the NumPy-Discussion