Skip to content

Instantly share code, notes, and snippets.

@esmitt
Last active October 14, 2020 15:37
Show Gist options
  • Save esmitt/81d3db8564a21eccb8d603d8216efef8 to your computer and use it in GitHub Desktop.
Save esmitt/81d3db8564a21eccb8d603d8216efef8 to your computer and use it in GitHub Desktop.
Prints statistics over an array of numbers using describe function from scipy and numpy range of values function (ptp)
from scipy.stats import describe
import numpy as np
# arr_values is a numpy array
def print_stats(arr_values: np.array) -> None:
stats = describe(arr_values)
print(f'min: {stats.minmax[0]:.5f}, max: {stats.minmax[1]:.4f}')
print(f'mean: {stats.mean:.5f}')
print(f'standard: {np.std(arr_values):.5f}')
print(f'variance: {stats.variance:.5f}')
print(f'skewness: {stats.skewness:.5f}')
print(f'kurtosis: {stats.kurtosis:.5f}')
print(f'range: {np.ptp(arr_values):.4f}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment