Exemplo n.º 1
0
def test_triangular(rnd, c, loc=0, scale=1):
    # triangular random variate generator
    triangular_dist = RVGs.Triangular(c, loc, scale)

    # obtain samples
    samples = get_samples(triangular_dist, rnd)

    # get theoretical variance
    var = scipy.triang.stats(c, loc, scale, moments='v')
    var = np.asarray(var).item()

    # report mean and variance
    print_test_results('Triangular',
                       samples,
                       expectation=(3 * loc + scale + c * scale) / 3.0,
                       variance=var)
Exemplo n.º 2
0
print("Fitting LogNormal:", dictResults)

# 12 NegativeBinomial
dist = RVGs.NegativeBinomial(3, 0.3, 1)
dat_neg_bin = np.array(get_samples(dist, np.random))  # mean, sigma
dictResults = Fit.fit_negative_binomial(dat_neg_bin, 'Data', fixed_location=1)
print("Fitting NegativeBinomial:", dictResults)

# 13 Normal
dist = RVGs.Normal(0, 1)
dat_norm = np.array(get_samples(dist, np.random))  # mean, sigma
dictResults = Fit.fit_normal(dat_norm, 'Data')  # fit
print("Fitting Normal:", dictResults)

# 14 Triangular
dist = RVGs.Triangular(0.5, loc=1, scale=2)
dat_tri = np.array(get_samples(dist, np.random))
dictResults = Fit.fit_triang(dat_tri, 'Data', fixed_location=1)  # fit
print("Fitting Triangular:", dictResults)

# 15 Uniform
dist = RVGs.Uniform(0, 1)
dat_unif = np.array(get_samples(dist, np.random))  # mean, sigma
dictResults = Fit.fit_uniform(dat_unif, 'Data')  # fit
print("Fitting Uniform:", dictResults)

# 16 UniformDiscrete
dist = RVGs.UniformDiscrete(0, 100)
dat_unifDis = np.array(get_samples(dist, np.random))
dictResults = Fit.fit_uniformDiscrete(dat_unifDis, 'Data')  # fit
print("Fitting UniformDiscrete:", dictResults)