Last active
January 15, 2023 18:08
-
-
Save carloocchiena/f65e1381a30004352561a606ee0ba51a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copy and paste the script on a Jupyter Notebook to have the | |
# table printed on screen | |
import numpy as np | |
import pandas as pd | |
from scipy.integrate import quad | |
def normal_probability_density(x): | |
constant = 1.0 / np.sqrt(2 * np.pi) | |
return(constant * np.exp((-x**2) / 2)) | |
standard_normal_table = pd.DataFrame(data=[], | |
index = np.round(np.arange(0, 3.5, .1), 2), | |
columns=np.round(np.arange(0.00, 0.1, 0.01), 2)) | |
for index in standard_normal_table.index: | |
for column in standard_normal_table.columns: | |
z = np.round(index + column, 2) | |
value, _ = quad(normal_probability_density, np.NINF, z) | |
standard_normal_table.loc[index, column] = value | |
standard_normal_table.index = standard_normal_table.index.astype(str) | |
standard_normal_table.columns = (str(column).ljust(4, '0') for column in standard_normal_table.columns) | |
standard_normal_table |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment