mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-07-01 04:14:19 +08:00
* Split out a rolling submenu for the rolling functions * Make a performance and a stats submenu. * Test the statistics functions * lint * lint * dupe test * pylint * ruff * Try tests quick * black magic signature funcs * fix my custom tests * Fix the existing imports/urls * push the api update * okay I figured out whats going on * this should be all of them * Correct docstringing examples --------- Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
"""Statistics Functions"""
|
|
|
|
from typing import Union
|
|
|
|
from numpy import (
|
|
mean as mean_np,
|
|
ndarray,
|
|
std,
|
|
var as var_np,
|
|
)
|
|
from pandas import DataFrame, Series
|
|
from scipy import stats
|
|
|
|
# Because python is weird and these being the same name as the fastapi router functions
|
|
# which overwrites the function signature, we add the _ after the function name
|
|
|
|
|
|
def kurtosis_(data: Union[DataFrame, Series, ndarray]) -> float:
|
|
"""Kurtosis is a measure of the "tailedness" of the probability distribution of a real-valued random variable."""
|
|
return stats.kurtosis(data)
|
|
|
|
|
|
def skew_(data: Union[DataFrame, Series, ndarray]) -> float:
|
|
"""Skewness is a measure of the asymmetry of the probability distribution of a
|
|
real-valued random variable about its mean."""
|
|
return stats.skew(data)
|
|
|
|
|
|
def mean_(data: Union[DataFrame, Series, ndarray]) -> float:
|
|
"""Mean is the average of the numbers."""
|
|
return mean_np(data)
|
|
|
|
|
|
def std_dev_(data: Union[DataFrame, Series, ndarray]) -> float:
|
|
"""Standard deviation is a measure of the amount of variation or dispersion of a set of values."""
|
|
return std(data)
|
|
|
|
|
|
def var_(data: Union[DataFrame, Series, ndarray]) -> float:
|
|
"""Variance is a measure of the amount of variation or dispersion of a set of values."""
|
|
return var_np(data)
|