コード例 #1
0
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])
        ]
コード例 #2
0
def random_normal() -> float:
    # Returns a random draw from a standard normal distribution
    return inverse_normal_cdf(random.random())
コード例 #3
0
##############################################################################################################
"""

# 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())
コード例 #4
0
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)
コード例 #6
0
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)
コード例 #7
0
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)