amachine.am_random API documentation

# amachine.am_random

View Source

     1from scipy.special import softmax
     2from scipy.stats import beta
     3import numpy as np
     4
     5def exp_uniform_blend(n: int, alpha: float) -> list[float]:
     6    exp_probs = np.exp(-np.arange(n))
     7    exp_probs /= exp_probs.sum()
     8    uniform = np.ones(n) / n
     9    return ((1 - alpha) * exp_probs + alpha * uniform).tolist()
    10
    11def beta_dist( n, a, b):
    12	points = np.linspace(0, 1, n + 2 )[ 1:-1]
    13	probs  = beta.pdf(points, a, b)
    14	return probs / probs.sum()
    15
    16def dirichlet_dist(n, alpha):
    17	return np.random.dirichlet(np.ones(n) * alpha)
    18
    19def uniform_dist( n ):
    20	return np.ones(n) / n

def exp_uniform_blend(n: int, alpha: float) -> list[float]: View Source

     6def exp_uniform_blend(n: int, alpha: float) -> list[float]:
     7    exp_probs = np.exp(-np.arange(n))
     8    exp_probs /= exp_probs.sum()
     9    uniform = np.ones(n) / n
    10    return ((1 - alpha) * exp_probs + alpha * uniform).tolist()

def beta_dist(n, a, b): View Source

    12def beta_dist( n, a, b):
    13	points = np.linspace(0, 1, n + 2 )[ 1:-1]
    14	probs  = beta.pdf(points, a, b)
    15	return probs / probs.sum()

def dirichlet_dist(n, alpha): View Source

    17def dirichlet_dist(n, alpha):
    18	return np.random.dirichlet(np.ones(n) * alpha)

def uniform_dist(n): View Source

    20def uniform_dist( n ):
    21	return np.ones(n) / n