示例#1
0
def D_N(empiric_dist, space, ex=Lab1.Ex1()):
    d_n = []
    for i in range(len(empiric_dist)):
        d_n.append(abs(empiric_dist[i] - ex.F(space[i])))
    return max(d_n)
示例#2
0
    # F_real = [Lab1.Ex1().F(x) for x in space]
    # for nr_of_samples in n:
    #
    #     F_empiric = empiric_distribution(randoms[0:nr_of_samples], space)
    #
    #     D.append(D_N(F_empiric,space))
    #
    # pyplot.plot(n,D,'r*')
    #
    # pyplot.xlabel('N')
    # pyplot.ylabel('D(N)')
    # pyplot.plot(space, F_real, 'o')
    # pyplot.plot(space, F_empiric, '*')
    nr_of_samples = 500
    keys = [random.uniform(0, 1) for i in range(nr_of_samples)]
    randoms = Lab1.Generator.generate_random_numbers(keys, Lab1.Ex1())

    F_empiric = empiric_distribution(randoms, space)

    fig = pyplot.figure()
    ax1 = fig.add_subplot(211)
    ax2 = fig.add_subplot(212)
    ax1.title.set_text(r'Dystrybuanta empiryczna')
    ax2.title.set_text(r'Estymator wariancji')

    pyplot.subplot(2, 1, 1)
    pyplot.plot(space, F_empiric)

    pyplot.subplot(2, 1, 2)
    pyplot.plot(space, empiric_variance(F_empiric, Lab1.Ex1().F, space))
    pyplot.show()