[SciPy-User] specifying range in scipy.stats.truncnorm
Fri Jul 27 12:07:15 CDT 2012
On Fri, Jul 27, 2012 at 12:30 PM, Joon Ro <email@example.com> wrote:
> I tried to use scipy.stats.truncnorm and found the way to specifying the
> parameters of truncated normal very confusing.
> I expected a, b parameter to be the specification of the interval where I
> want to truncate the distribution at, but it is not the case when the normal
> I want to use is not standard.
> According to the documentation, I need to standardize my values - for
> example, if I want to have a truncated normal with mean 0.5, variance 1, on
> [0, 1] interval, I need to do:
> myclip_a = 0
> myclip_b = 1
> my_std =1
> a, b = (myclip_a - my_mean) / my_std, (myclip_b - my_mean) / my_std
> rv = truncnorm(a, b, loc=my_mean, scale=my_std)
> Which is unnecessarily complicated in my opinion. Since we have to provide
> location and scale parameter anyway, why not make truncnorm to accept the
> actual interval values (in this case, a, b = 0, 1) instead and do the
> standardization internally? I think it would be more intuitive that way.
I agree there are several cases of distributions where the
parameterization is not very intuitive or common. The problem is loc
and scale and the corresponding transformation of the support is done
So, I don't think it's possible to change this without a change in the
generic setup for the distributions or writing a specific dispatch
function or class that does the conversion.
I think, changing the generic setup would break the standard behavior
of distributions that have a predefined finite support limit, like
those that are defined for positive real numbers, a=0, or rdist with
> Best regards,
> SciPy-User mailing list
More information about the SciPy-User