Skip to content

Instantly share code, notes, and snippets.

@saimadhu-polamuri
Created October 19, 2023 12:59
Show Gist options
  • Save saimadhu-polamuri/c3bfcdb337f9f53245ae1fe531865a27 to your computer and use it in GitHub Desktop.
Save saimadhu-polamuri/c3bfcdb337f9f53245ae1fe531865a27 to your computer and use it in GitHub Desktop.
from scipy.stats import jarque_bera
import numpy as np
# generate two sample datasets
data1 = np.random.normal(0, 1, size=100)
data2 = np.random.uniform(size=100)
# perform Jarque-Bera test on each dataset
jb_stat1, jb_p1 = jarque_bera(data1)
jb_stat2, jb_p2 = jarque_bera(data2)
# print the results
print("Jarque-Bera statistic (data1):", jb_stat1)
print("p-value (data1):", jb_p1)
print("Jarque-Bera statistic (data2):", jb_stat2)
print("p-value (data2):", jb_p2)
# perform hypothesis testing
alpha = 0.05
if jb_p1 > alpha:
print("The null hypothesis (data1 comes from a normal distribution) cannot be rejected.")
else:
print("The null hypothesis (data1 comes from a normal distribution) is rejected.")
if jb_p2 > alpha:
print("The null hypothesis (data2 comes from a normal distribution) cannot be rejected.")
else:
print("The null hypothesis (data2 comes from a normal distribution) is rejected.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment