ts_shape.events.quality.value_distribution
Value distribution: shape and stability of a signal's values.
Detects mode changes and bimodality, tests normality per window, and tracks percentiles over time: the distribution checks behind capability indices and SPC limits.
| Name | Description |
|---|---|
ValueDistributionEvents | Quality: Value Distribution Analysis |
ValueDistributionEvents
ValueDistributionEvents(
dataframe: pd.DataFrame,
signal_uuid: str,
*,
event_uuid: str = "quality:distribution",
value_column: str = "value_double",
time_column: str = "systime"
) -> None
Bases: Base
Quality: Value Distribution Analysis
Answer the question "is my process behaving normally?" by examining the statistical distribution of a numeric signal over time.
Methods:
- detect_mode_changes: Detect shifts between distinct operating modes.
- detect_bimodal: Test whether the signal has a bimodal distribution.
- normality_windows: Flag time windows with non-normal distributions.
- percentile_tracking: Track selected percentiles over time windows.
| Name | Description |
|---|---|
detect_mode_changes | Detect shifts between distinct operating modes. |
detect_bimodal | Test whether the overall signal distribution is bimodal. |
normality_windows | Flag time windows whose values are not normally distributed. |
percentile_tracking | Track selected percentiles over time windows. |
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Long-format timeseries frame (one row per sample, uuid identifies the signal). | required |
signal_uuid | str | UUID of the signal to analyze. | required |
event_uuid | str | UUID stamped on emitted events. | 'quality:distribution' |
value_column | str | Column holding the signal values. | 'value_double' |
time_column | str | Timestamp column. | 'systime' |
detect_mode_changes
detect_mode_changes(
window: str = "1h", n_modes: int = 2, min_separation: float = 1.0
) -> pd.DataFrame
Detect shifts between distinct operating modes.
Splits the signal into time windows, computes the histogram peaks (modes) in each window, and flags when the dominant mode shifts.
| Name | Type | Description | Default |
|---|---|---|---|
window | str | Time window for analysis. | '1h' |
n_modes | int | Maximum number of modes to look for per window. | 2 |
min_separation | float | Minimum separation between modes in units of the signal's standard deviation to count as distinct. | 1.0 |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end, duration_seconds, uuid, |
DataFrame | source_uuid, dominant_mode, n_modes_detected, mode_count (the |
DataFrame | number of modes found in the window), mode_values, mode_changed. |
DataFrame | end is start plus one window. |
DataFrame | Canonical twin columns: mode_count (after n_modes_detected); it holds the same |
DataFrame | values as the deprecated column right before it, which is removed |
DataFrame | in the next major release. |
detect_bimodal
detect_bimodal(min_samples: int = 30) -> pd.DataFrame
Test whether the overall signal distribution is bimodal.
Uses Hartigan's dip test statistic approximated via the sorted data's inter-mode gap relative to overall range. A simpler, dependency-free alternative to the full dip test.
| Name | Type | Description | Default |
|---|---|---|---|
min_samples | int | Minimum sample count required to run the test. | 30 |
| Type | Description |
|---|---|
DataFrame | Single-row DataFrame with columns: is_bimodal, dip_score, |
DataFrame | n_samples, mode_1, mode_2, valley (empty when there are fewer |
DataFrame | than min_samples values). A constant signal is unimodal with |
DataFrame | mode_1 at its value. |
DataFrame | Canonical twin columns: sample_count (after n_samples); each holds |
DataFrame | the same values as the deprecated column right before it, which is removed |
DataFrame | in the next major release. |
normality_windows
normality_windows(
window: str = "1h", alpha: float = 0.05, min_samples: int = 20
) -> pd.DataFrame
Flag time windows whose values are not normally distributed.
Uses the Shapiro-Wilk test per window.
| Name | Type | Description | Default |
|---|---|---|---|
window | str | Resample window. | '1h' |
alpha | float | Significance level for the normality test. | 0.05 |
min_samples | int | Minimum samples per window to run the test. | 20 |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end, duration_seconds, uuid, |
DataFrame | source_uuid, n_samples, is_normal, p_value, skewness, kurtosis. |
DataFrame | end is start plus one window. |
DataFrame | Canonical twin columns: sample_count (after n_samples); each holds |
DataFrame | the same values as the deprecated column right before it, which is removed |
DataFrame | in the next major release. |
percentile_tracking
percentile_tracking(
percentiles: Sequence[float] = (5, 25, 50, 75, 95), window: str = "1h"
) -> pd.DataFrame
Track selected percentiles over time windows.
Useful for spotting distribution spread changes even when the mean stays constant.
| Name | Type | Description | Default |
|---|---|---|---|
percentiles | Sequence[float] | Percentile values to track (0-100). | (5, 25, 50, 75, 95) |
window | str | Resample window. | '1h' |
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: start, end, duration_seconds, uuid, |
DataFrame | source_uuid, n_samples, plus one column per percentile (e.g. |
DataFrame | p5, p95). end is start plus one window. |
DataFrame | Canonical twin columns: sample_count (after n_samples); each holds |
DataFrame | the same values as the deprecated column right before it, which is removed |
DataFrame | in the next major release. |