Skip to content

Mann-Kendall Trend Test

Source: src/mann_kendall.rs

This module provides an implementation of the Mann-Kendall trend test for Polars Series.

The Mann-Kendall test checks for a trend in a time series by comparing each data point to subsequent data points. It computes a statistic S indicating how many pairs are in increasing vs. decreasing order and then normalizes it via [ S / (0.5 * n * (n - 1)) ], matching standard Mann-Kendall definitions.

Python API

mann_kendall

mann_kendall(...)

Apply the Mann-Kendall trend test to the first Series in inputs.

Parameters

Parameter Description
inputs a slice of Series, with the first entry expected to be a float Series (f64).

Returns

A single-valued Float64 Series containing the normalized Mann-Kendall statistic. This matches the Python version mk_stat = S / (0.5 * n * (n - 1)).

Errors

Returns an error if the first Series is not of f64 type or if it contains nulls.

Internal Functions

These are internal Rust functions not directly callable from Python.

query

Query how many increments occur up to and including index i in the Fenwick tree.