[Python] Types of statistical values (features) and calculation methods

import

It uses numpy and scipy, so please import it first.

import



import numpy as np
import scipy.stats

Maximum value, minimum value

max,min


#Maximum value
np.max(data)

#minimum value
np.min(data)

Median

median


#Median
np.median(data)

Mean, variance, standard deviation

When the variance and standard deviation are calculated using Numpy, the unbiased variance and unbiased standard deviation are returned by default.

mean,var,std


#average
np.mean(data)

#Distributed
np.var(data)

#standard deviation
np.std(data)

Skewness, kurtosis

skew,kurt


#skewness
scipy.stats.skew(data)

#kurtosis
scipy.stats.kurtosis(data)

Root mean square

rms


#Root mean square
np.sqrt(np.square(data).mean())

Frequency domain entropy

ent


# FFT
fft_data = np.fft.fft(data)

#Power spectrum
power_data = abs(fft_data)**2

#Power spectrum ratio
p = power_data / sum(power_data)

#Frequency domain entropy

ent(data)

def ent(data):
   ent = 0
   for i in range(data_size):
       ent += data[i]*np.log2(data[i])
   return -ent

Recommended Posts

[Python] Types of statistical values (features) and calculation methods
[Python] Various combinations of strings and values
Calculation of standard deviation and correlation coefficient in Python
Python --Check type of values
About the features of Python
Source installation and installation of Python
[Python] Heron's formula functionalization and calculation of the maximum area
Python: Create a dictionary from a list of keys and values
I want to know the features of Python and pip
Environment construction of python and opencv
Calculation of homebrew class and existing class
This and that of python properties
[Python] Calculation of Kappa (k) coefficient
Coexistence of Python2 and 3 with CircleCI (1.0)
Summary of Python indexes and slices
Python classes and instances, instance methods
Reputation of Python books and reference books
[Python] Three methods to compare the list of one-dimensional array and the list of two-dimensional array and extract only the matching values [json]
I replaced the numerical calculation of Python with Rust and compared the speed
[Python] Summary of conversion between character strings and numerical values (ascii code)
[Control engineering] Calculation of transfer functions and state space models by Python
Installation of Visual studio code and installation of python
Statistical basics and Python, graphing, etc. (memo)
Example of using class variables and class methods
Bind methods to Python classes and instances
Connect a lot of Python or and and
[Python] Calculation of image similarity (Dice coefficient)
Correlation visualization of features and objective variables
Private methods and fields in python [encryption]
1. Statistics learned with Python 1-3. Calculation of various statistics (statistics)
Summary of built-in methods in Python list
Easy introduction of python3 series and OpenCV3
Idempotent automation of Python and PyPI setup
Real-time calculation of mean values with coroutines
Project Euler # 1 "Multiples of 3 and 5" in Python
[Python] A program that finds the minimum and maximum values without using methods
Correspondence summary of array operation of ruby and python
[Python] How to use two types of type ()
Complementing kaggle's titanic missing values and creating features
Python variables and data types learned in chemoinformatics
Summary of the differences between PHP and Python
[python] Create a list of various character types
Python numpy ignores very small values ​​and displays
List of frequently used built-in functions and methods
The answer of "1/2" is different between python2 and 3
How python classes and magic methods are working.
Organize the meaning of methods, classes and objects
Specifying the range of ruby and python arrays
[Python] Takes representative values ​​of multiple images [Numpy]
Calculation of elapsed years and elapsed months including leap years
Installation of Python3 and Flask [Environment construction summary]
1. Statistics learned with Python 1-2. Calculation of various statistics (Numpy)
Compare the speed of Python append and map
Calculation of technical indicators by TA-Lib and pandas
Calculation of match rate of character string breaks [python]
Testing methods that return random values in Python
Implementation of TRIE tree with Python and LOUDS
python development environment -use of pyenv and virtualenv-
Links and memos of Python character code strings
I touched some of the new features of Python 3.8 ①
Frequently used methods of Selenium and Beautiful Soup