Пример #1
0
def histogram(arguments):

    data = list(map(float, sys.stdin.readlines()))
    data_min = min(data)
    data_avg = pylab.average(pylab.array(data))
    data_max = max(data)
    data_std = pylab.std(pylab.array(data))

    data = filter(
        lambda n: data_avg + arguments.n * data_std > (n**2)**0.5, data)

    pyplot.hist(list(data), bins=arguments.bins)
    pyplot.suptitle(arguments.suptitle)

    if arguments.title is None:
        pyplot.title('min|avg|max|std = {0:0.2f}|{1:0.2f}|{2:0.2f}|{3:0.2f}'
            .format(data_min, data_avg, data_max, data_std))
    else:
        pyplot.title(arguments.title)

    pyplot.xlabel(arguments.xlabel)
    pyplot.ylabel(arguments.ylabel)
    pyplot.grid()

    pyplot.savefig(path(arguments))
Пример #2
0
def make_error(data_file, xin=None):
    databox = spinmob.data.load(data_file)
    errs = []
    xs = databox.c('c8')
    xs -= xs[0]
    for i in range(6):
        vals = databox.c('c{:d}'.format(i))
        if xin:
            vals = pylab.array([v for x, v in zip(xs, vals) if xin[0] <= x <= xin[1]])
        std = pylab.std(vals)
        errs.append(std)
    err = pylab.mean(errs)
    return err, errs
def print_stats(list_1):
    print("\t N\t", len(list_1))
    print("\t mean\t", pylab.mean(list_1))
    print("\t error\t", pylab.std(list_1) / pylab.sqrt(len(list_1)))
Пример #4
0
receptive_field = K * (2**D * 2) - (K - 1)
receptive_field_ms = receptive_field * 1000 / sr
print("Receptive field: {0}".format(receptive_field))
print("Receptive field: {0:.4} ms".format(receptive_field_ms))

# x = P.hstack([x + P.randn(len(x))*.02*v, x + P.randn(len(x))*.01*v, x])
# y = P.hstack([y, y, y])

print("Calculating error stats...")
ah = 8
a = y.reshape(-1)[:-ah]
ax = x.reshape(-1)
print("VARIANCE")
print(P.var(a))
print("STD")
print(P.std(a))
A = P.vstack([a[i:(i - ah)] for i in range(ah)])
AX = P.vstack([ax[i:(i - 2 * ah)] for i in range(2 * ah)])
A = P.vstack([A, AX, ax[2 * ah:]])
b = a[ah:]
A = A - P.mean(A, 1).reshape(-1, 1)
b = b - P.mean(b)
print("LMMSE with {0} taps".format(ah))
LMMSE = P.mean((b - A.T.dot(P.inv(P.dot(A, A.T)).dot(A.dot(b))))**2)
print(LMMSE)
print("LMRMSE with {0} taps".format(ah))
print(P.sqrt(LMMSE))


def mu_law(a, mu=256, MAX=None):
    mu = mu - 1