Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python script for computing descriptive statistics

import numpy as np
import matplotlib.pyplot as plt
import scipy.stats

dist = np.array([ 1, 4, 5, 6, 8, 8, 9, 10, 10, 11, 11, 13, 13, 13, 14, 14, 15, 15, 15, 15 ])

print('Descriptive statistics for distribution:
', dist)
print('Number of scores:', len(dist))
print('Number of unique scores:', len(np.unique(dist))
print('Sum:', sum(dist))
print('Min:', min(dist))
print('Max:', max(dist))
print('Range:', max(dist)-min(dist))
print('Mean:', np.mean(dist, axis=0))
print('Median:', np.median(dist, axis=0))
print('Mode:', scipy.stats.mode(dist)[0][0])
print('Variance:', np.var(dist, axis=0))
print('Standard deviation:', np.std(dist, axis=0))
print('1st quartile:', np.percentile(dist, 25))
print('3rd quartile:', np.percentile(dist, 75))
print('Distribution skew:', scipy.stats.skew(dist))

plt.hist(dist, bins=len(dist))
plt.yticks(np.arange(0, 6, 1.0))
plt.title('Histogram of distribution scores')
plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: python tkinter checkbox default value 
Python :: python sort by length and alphabetically 
Python :: gyp err! stack error: command failed: c:python39python.exe -c import sys; print "%s.%s.%s" % sys.version_info[:3]; 
Python :: Aggregate on the entire DataFrame without group 
Python :: access column pandas 
Python :: math module sin() function in python 
Python :: Converting Categorical variables in to integers using Dummy 
Python :: python slice list 
Python :: simple seaborn heatmap 
Python :: python is instance 
Python :: function wrapper with variable number of arguments python 
Python :: list all files in python 
Python :: how to improve accuracy of random forest classifier 
Python :: stack in python using linked list 
Python :: python os.path.join 
Python :: super title python 
Python :: python check if input contains letters 
Python :: dataframe look at every second column 
Python :: why are my static files not loading in django 
Python :: pandas split tuple column 
Python :: lucky number codechef solution 
Python :: print data type array 
Python :: exit code python 
Python :: Python __mul__ 
Python :: moving element to last position in a list python 
Python :: SUMOFPROD1 
Python :: save and load model during training pytorch 
Python :: pyqt5 drop down menu 
Python :: split string to list 
Python :: chatterbot python 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =