I have an array of random samples from a normal distribution where I want to evaluate the CDF of each element in place
import numpy as np
arr = np.random.normal(0, 1, 10000)
arr
array([-0.03960733, -0.58329607, -1.55133923, ..., -0.94473672,
1.24757701, -0.66197476])
I know I could do this using scipy.stats.norm().cdf
, but I am restricted to only using numpy.
I have found this SO post that outlines how to do something similar using numpy.histogram
and numpy.cumsum
. How can I extend this (using only numpy) to evaluate the CDF of each element in place, so the output array is as below
from scipy import stats
stats.norm().cdf(arr)
array([0.48420309, 0.279847 , 0.06041021, ..., 0.17239665, 0.893907 ,
0.2539937 ])