| |
- is_monotonic_incr(x)
- Check if x is monotonically increasing.
Returns 1 if x is monotonically increasing and 0 if not. If x is
floating point, safe comparisons are used in the algorithm to
determine whether x is monotonically increasing; 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_incr import is_monotonic_incr
>>> x = [20., -32., -1., 2., 5., 29.]
>>> is_monotonic_incr(x)
0
>>> x = (-32., -1., 2., 5., 29.)
>>> is_monotonic_incr(x)
1
>>> x = N.array([4, 6, 7, 9])
>>> is_monotonic_incr(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_incr(x)
1
>>> x = N.array([1.00000001, 1.00000002, 1.00000003])
>>> is_monotonic_incr(x)
0
|