Skip to content

Commit e4331b2

Browse files
committed
STY: stats.lmoment: style adjustments per review
1 parent ca9d157 commit e4331b2

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

scipy/stats/_stats_py.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10199,7 +10199,7 @@ def first_order(t):
1019910199
return res.root
1020010200

1020110201

10202-
def lmoment_iv(sample, order, axis, sorted, standardize):
10202+
def _lmoment_iv(sample, order, axis, sorted, standardize):
1020310203
# input validation/standardization for `lmoment`
1020410204
sample = np.asarray(sample)
1020510205
message = "`sample` must be an array of real numbers."
@@ -10246,6 +10246,9 @@ def _br(x, *, r=0):
1024610246

1024710247

1024810248
def _prk(r, k):
10249+
# Writen to match [1] Equation 27 closely to facilitate review.
10250+
# This does not protect against overflow, so improvements to
10251+
# robustness would be a welcome follow-up.
1024910252
return (-1)**(r-k)*special.binom(r, k)*special.binom(r+k, k)
1025010253

1025110254

@@ -10270,8 +10273,11 @@ def lmoment(sample, order=None, *, axis=0, sorted=False, standardize=True):
1027010273
order : array_like, optional
1027110274
The (positive integer) orders of the desired L-moments.
1027210275
Must be a scalar or non-empty 1D array. Default is [1, 2, 3, 4].
10273-
axis : int, default=0
10274-
The axis along which to compute L-moments.
10276+
axis : int or None, default=0
10277+
If an int, the axis of the input along which to compute the statistic.
10278+
The statistic of each axis-slice (e.g. row) of the input will appear
10279+
in a corresponding element of the output. If None, the input will be
10280+
raveled before computing the statistic.
1027510281
sorted : bool, default=False
1027610282
Whether `sample` is already sorted in increasing order along `axis`.
1027710283
If False (default), `sample` will be sorted.
@@ -10295,6 +10301,10 @@ def lmoment(sample, order=None, *, axis=0, sorted=False, standardize=True):
1029510301
.. [1] D. Bilkova. "L-Moments and TL-Moments as an Alternative Tool of
1029610302
Statistical Data Analysis". Journal of Applied Mathematics and
1029710303
Physics. 2014. :doi:`10.4236/jamp.2014.210104`
10304+
.. [2] J. R. M. Hosking. "L-Moments: Analysis and Estimation of Distributions
10305+
Using Linear Combinations of Order Statistics". Journal of the Royal
10306+
Statistical Society. 1990. :doi:`10.1111/j.2517-6161.1990.tb01775.x`
10307+
.. [3] "L-moment". *Wikipedia*. https://en.wikipedia.org/wiki/L-moment.
1029810308
1029910309
Examples
1030010310
--------
@@ -10310,12 +10320,12 @@ def lmoment(sample, order=None, *, axis=0, sorted=False, standardize=True):
1031010320
provide reasonable estimates.
1031110321
1031210322
"""
10313-
args = lmoment_iv(sample, order, axis, sorted, standardize)
10323+
args = _lmoment_iv(sample, order, axis, sorted, standardize)
1031410324
sample, order, axis, sorted, standardize = args
1031510325

1031610326
n_moments = np.max(order)
1031710327
k = np.arange(n_moments, dtype=sample.dtype)
10318-
prk = _prk(np.expand_dims(k, list(range(1, sample.ndim+1))), k)
10328+
prk = _prk(np.expand_dims(k, tuple(range(1, sample.ndim+1))), k)
1031910329
bk = _br(sample, r=k)
1032010330

1032110331
n = sample.shape[-1]

0 commit comments

Comments
 (0)