def random_normal(*dims: int, mean: float = 0.0, variance: float = 1.0) -> Tensor: if len(dims) == 1: return [ mean + variance * inverse_normal_cdf(random.random()) for _ in range(dims[0]) ] else: return [ random_normal(*dims[1:], mean=mean, variance=variance) for _ in range(dims[0]) ]
def random_normal() -> float: # Returns a random draw from a standard normal distribution return inverse_normal_cdf(random.random())
############################################################################################################## """ # Data import random from Probability import inverse_normal_cdf random.seed(0) # Data 1 #uniform between -100 and 100 uniform = [200 * random.random() - 100 for _ in range(10000)] #Data 2 #normal distrinution with mean 0, standard deviation 57 normal = [57 * inverse_normal_cdf(random.random()) for _ in range(10000)] # Plot Data 1 plot_histogram(uniform, 10, "Uniform Histogram") # Plot Data 2 plot_histogram(normal, 10, "Normal Histogram") """ ############################################################################################################## ########################## 2-dimensional data ########################## ############################################################################################################## """ def random_normal() -> float: # Returns a random draw from a standard normal distribution return inverse_normal_cdf(random.random())
def normal_lower_bound(probability: float, mu: float = 0, sigma: float = 1) -> float: """Returns the z for which P(Z >= z) = probability""" return inverse_normal_cdf(1 - probability, mu, sigma)
def normal_upper_bound(probability:float, mu:float = 0, sigma: float = 1)-> float: # Returns the z for which P(Z<=z) = probability return inverse_normal_cdf(probability, mu, sigma)
def normal_lower_bound(probability, mu=0, sigma=1): """return the z for which P(Z >= z) = probability""" return inverse_normal_cdf(1 - probability, mu, sigma)
def normal_upper_bound(probability, mu=0, sigma=1): """returns the z for which P(Z <= z) = probability""" return inverse_normal_cdf(probability, mu, sigma)