@@ -10199,7 +10199,7 @@ def first_order(t):
10199
10199
return res .root
10200
10200
10201
10201
10202
- def lmoment_iv (sample , order , axis , sorted , standardize ):
10202
+ def _lmoment_iv (sample , order , axis , sorted , standardize ):
10203
10203
# input validation/standardization for `lmoment`
10204
10204
sample = np .asarray (sample )
10205
10205
message = "`sample` must be an array of real numbers."
@@ -10246,6 +10246,9 @@ def _br(x, *, r=0):
10246
10246
10247
10247
10248
10248
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.
10249
10252
return (- 1 )** (r - k )* special .binom (r , k )* special .binom (r + k , k )
10250
10253
10251
10254
@@ -10270,8 +10273,11 @@ def lmoment(sample, order=None, *, axis=0, sorted=False, standardize=True):
10270
10273
order : array_like, optional
10271
10274
The (positive integer) orders of the desired L-moments.
10272
10275
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.
10275
10281
sorted : bool, default=False
10276
10282
Whether `sample` is already sorted in increasing order along `axis`.
10277
10283
If False (default), `sample` will be sorted.
@@ -10295,6 +10301,10 @@ def lmoment(sample, order=None, *, axis=0, sorted=False, standardize=True):
10295
10301
.. [1] D. Bilkova. "L-Moments and TL-Moments as an Alternative Tool of
10296
10302
Statistical Data Analysis". Journal of Applied Mathematics and
10297
10303
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.
10298
10308
10299
10309
Examples
10300
10310
--------
@@ -10310,12 +10320,12 @@ def lmoment(sample, order=None, *, axis=0, sorted=False, standardize=True):
10310
10320
provide reasonable estimates.
10311
10321
10312
10322
"""
10313
- args = lmoment_iv (sample , order , axis , sorted , standardize )
10323
+ args = _lmoment_iv (sample , order , axis , sorted , standardize )
10314
10324
sample , order , axis , sorted , standardize = args
10315
10325
10316
10326
n_moments = np .max (order )
10317
10327
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 )
10319
10329
bk = _br (sample , r = k )
10320
10330
10321
10331
n = sample .shape [- 1 ]
0 commit comments