Outlier detection for semi-normal distributions using the mirroring technique
Project description
My sire, that is an Outlier!
Outlier detection for semi-normal distributions.
Most outlier detection methods assume your data is fully normal. But what if it's only half normal — a clear peak with one meaningful tail? my-sire-that-is-an-outlier handles exactly that.
How it works
- Find the peak of your distribution (via KDE or max value)
- Take the tail-side data (everything at or below the peak)
- Mirror it across the peak to create a synthetic full normal distribution
- Compute mean and std of the synthetic distribution
- Flag anything below
mean − threshold × stdas an outlier
Installation
pip install my-sire-that-is-an-outlier
Quick start
from my_sire_that_is_an_outlier import find_outliers
# Example: exam scores — most students score high, outliers at the low end
scores = [95, 97, 92, 88, 91, 99, 100, 94, 96, 72, 65, 55, 48]
result = find_outliers(scores, method="mode", threshold=2)
print(result["outliers"]) # array([48])
print(result["cutoff"]) # e.g. 62.4
API
find_outliers(data, method="mode", threshold=2.0)
| Parameter | Type | Default | Description |
|---|---|---|---|
data |
list / np.ndarray / pd.Series | required | 1-D numeric data. NaNs are ignored. |
method |
"mode" or "max" |
"mode" |
How to locate the peak of the distribution. |
threshold |
float | 2.0 |
Sigmas below the mirror mean to cut off at. |
Return value
A dict with:
| Key | Description |
|---|---|
outliers |
np.ndarray of values identified as outliers |
cutoff |
The threshold value — points below this are outliers |
mirror_mean |
Mean of the synthetic mirrored distribution |
mirror_std |
Std dev of the synthetic mirrored distribution |
method parameter
"mode"(default) — uses KDE to find the most-dense region of the data as the peak. Best for real-world, noisy data."max"— uses the maximum value as the peak. Useful when your data is naturally bounded at the top (e.g. a 100-point exam, property values with a known ceiling).
threshold parameter
Controls sensitivity. A value of 2.0 means any point more than 2 standard deviations below the mirror mean is flagged. Increase for fewer (more extreme) outliers; decrease for more.
When to use this
my-sire-that-is-an-outlier works well when your data:
- Has a clear, single peak
- Has one natural tail (skewed left or right)
- Is not bimodal or uniformly distributed
Examples: exam scores, property values, response times, sensor readings with a hard ceiling.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file my_sire_that_is_an_outlier-0.1.1.tar.gz.
File metadata
- Download URL: my_sire_that_is_an_outlier-0.1.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f57d9ff7ed2201de95b700067b16fb901b55a5d51097ea4f48802aff377b669
|
|
| MD5 |
15183c7041ac1d037c1138c53fe8238c
|
|
| BLAKE2b-256 |
1b2548dec90fb0caaf1a6f2b07a24d5f603dc6289028e8bf0f52843882080ae3
|
File details
Details for the file my_sire_that_is_an_outlier-0.1.1-py3-none-any.whl.
File metadata
- Download URL: my_sire_that_is_an_outlier-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6be41dc5bc0323f4b2dcad0fd6b8d056a3333e679af5273380139434d1cf569
|
|
| MD5 |
d68febca8a9983e089b9ff0009cbac85
|
|
| BLAKE2b-256 |
b7e58c004a2c87d8852df3e04dd985368ab3a29ebd0e2db054be75b97d5b1a69
|