• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Crypto Currency
  • Technology
NEO Share

NEO Share

Sharing The Latest Tech News

  • Home
  • Artificial Intelligence
  • Machine Learning
  • Computers
  • Mobile
  • Crypto Currency

Kolmogorov–Smirnov test(KS Test) in Python

December 26, 2020 by systems

Kunal Mahajan

KS Test is used to check if two continuous distributions follow the same distribution or not. Below is the Python code for performing KS Test.

# Import Libraries
import numpy as np
import seaborn as sns
from scipy import stats
import matplotlib.pyplot as plt

#Generating Normal Random Variable X
x = stats.norm.rvs(size= 100)

#Draw Kernel Density Estimation Plot for X
sns.kdeplot(np.array(x),bw = 0.5)
plt.show()

#Use kstest function available under scipy to compare X with Normal Distribution.

stats.kstest(x, ‘norm’)

#Output :
KstestResult(statistic=0.063772217543546034, value=0.81075786049050036)

Conclusion:

P-value is higher than the Significance level(Also known as Alpha .05 in our case) so we accept the Null Hypothesis which implies x is normally distributed.

Follow us to get more such articles.

Filed Under: Artificial Intelligence

Primary Sidebar

Netflix reportedly working to add support for Apple’s Spatial Audio

Generate Images From Texts

Social Media: What if we had a “Reset” Button?

What are your thoughts on Samsung’s new Galaxy S21 series?

Saudi Arabia makes artificial intelligence a cornerstone of its 2030 vision

Footer

  • Privacy Policy
  • Terms and Conditions

Copyright © 2021 NEO Share

Terms and Conditions - Privacy Policy