Skip to main content

Confidence Based Smoothing

The algorithm smooths functions preserving local peaks. To distinguish peaks from noise it needs noise standard deviation.

Demo

Installation

pip install --upgrade confsmooth

Usage

import os, shutil, statsmodels
import matplotlib.pyplot as plt
import numpy as np
from statsmodels.nonparametric.kernel_regression import KernelReg
from confsmooth import confsmooth
from scipy.signal import savgol_filter

x = np.linspace(-2,2,500)
real_noise_level = 0.002
y = 1 - np.power(np.abs(x)+0.01,0.01) + np.random.normal(0, real_noise_level, len(x))

# estimate noise standard deviation
savgol = savgol_filter(y,21,1)
noise_level = np.std(y - savgol)
print('Estimated noise level =', noise_level, 'Real noise level =', real_noise_level)

smoothed_conf = confsmooth(y, noise_level, confidence=0.995, deg=2)

kr = KernelReg(endog=y, exog=x, var_type='c', bw=[0.1])
smoothed_kr, _ = kr.fit(x)

fig,ax = plt.subplots()
ax.plot(x, y, label='initial')
ax.plot(x, savgol, label='savgol')
ax.plot(x, smoothed_kr, label='Kernel regr')
ax.plot(x, smoothed_conf, label='confsmooth')
ax.legend()
plt.show()

Metadata

Release files for confsmooth 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for confsmooth 1.0.0
File Interpreter ABI Platform
confsmooth-1.0.0-py3-none-any.whl Python 3 none any Details

Release files / confsmooth-1.0.0-py3-none-any.whl

Download URL confsmooth-1.0.0-py3-none-any.whl
Size 3.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
01c15ee4a5834f9a7e7dbcf42a46ac84381c0cef5f79a05e9c5ea24469d3adba
BLAKE2b-256 checksum
How to use checksums
0f447d24523e1fd39c64cbf385182c79d57451743e975d00003d9306cfeb8f5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Security for confsmooth 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page