Exemplo n.º 1
0
def test_poisson(rnd, mu, loc=0):
    # poisson random variate generator
    poisson_dist = RVGs.Poisson(mu, loc)

    # obtain samples
    samples = get_samples(poisson_dist, rnd)

    # report mean and variance
    print_test_results('Poisson', samples, expectation=mu + loc, variance=mu)
Exemplo n.º 2
0
def test_fitting_poisson():

    print("\nTesting Poisson with mean=100 and loc = 10")
    dist = RVGs.Poisson(mu=100, loc=10)
    print('  percentile interval: ', dist.get_percentile_interval(alpha=0.05))

    data = np.array(get_samples(dist, np.random))
    dict_mm_results = RVGs.Poisson.fit_mm(mean=np.average(data),
                                          fixed_location=10)
    dict_ml_results = RVGs.Poisson.fit_ml(data=data, fixed_location=10)

    print("  Fit:")
    print("    MM:", dict_mm_results)
    print("    ML:", dict_ml_results)

    # plot the fitted distributions
    Plot.plot_poisson_fit(data=data,
                          fit_results=dict_mm_results,
                          title='Method of Moment')
    Plot.plot_poisson_fit(data=data,
                          fit_results=dict_ml_results,
                          title='Maximum Likelihood')