| |
- is_monotonic_decr(x)
- Check if x is monotonically decreasing.
Returns 1 if x is monotonically decreasing and 0 if not. If x is
floating point, safe comparisons are used in the algorithm to
determine whether x is monotonically decreasing; if x is integer,
exact comparison is used.
Positional Input Arguments:
* x: Rank 1 list, tuple, or Numeric array of any numerical type.
Must be greater than 1-element long.
Keyword Input Arguments: None.
Examples:
>>> import Numeric as N
>>> from is_monotonic_decr import is_monotonic_decr
>>> x = [20., -32., -1., 2., -5., 29.]
>>> is_monotonic_decr(x)
0
>>> x = (32., 1., -2., -5., -29.)
>>> is_monotonic_decr(x)
1
>>> x = N.array([14, -6, -7, -19])
>>> is_monotonic_decr(x)
1
Note: Because of the limits of floating point, even safe-compar-
isons will not always return the correct answer. Thus, in the
first example below, the correct answer is returned, but in the
second example, the incorrect answer is returned:
>>> x = N.array([-1.0000001, -1.0000002, -1.0000003])
>>> is_monotonic_decr(x)
1
>>> x = N.array([-1.00000001, -1.00000002, -1.00000003])
>>> is_monotonic_decr(x)
0
|