Loading [MathJax]/extensions/tex2jax.js
scipy 1.10.1 Pypi GitHub Homepage
Other Docs

Parameters
trim(a, limits=None, inclusive=(True, True), relative=False, axis=None)

Returns a masked version of the input array.

Parameters

a : sequence

Input array

limits : {None, tuple}, optional

If relative is False, tuple (lower limit, upper limit) in absolute values. Values of the input array lower (greater) than the lower (upper) limit are masked.

If relative is True, tuple (lower percentage, upper percentage) to cut on each side of the array, with respect to the number of unmasked data.

Noting n the number of unmasked data before trimming, the (n*limits[0])th smallest data and the (n*limits[1])th largest data are masked, and the total number of unmasked data after trimming is n*(1.-sum(limits)) In each case, the value of one limit can be set to None to indicate an open interval.

If limits is None, no trimming is performed

inclusive : {(bool, bool) tuple}, optional

If relative is False, tuple indicating whether values exactly equal to the absolute limits are allowed. If relative is True, tuple indicating whether the number of data being masked on each side should be rounded (True) or truncated (False).

relative : bool, optional

Whether to consider the limits as absolute values (False) or proportions to cut (True).

axis : int, optional

Axis along which to trim.

Trims an array by masking the data outside some given limits.

Examples

from scipy.stats.mstats import trim
z = [ 1, 2, 3, 4, 5, 6, 7, 8, 9,10]
print(trim(z,(3,8)))
print(trim(z,(0.1,0.2),relative=True))
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/stats/_mstats_basic.py#1902
type: <class 'function'>
Commit: