예제 #1
0
def try_square_wave(period, noise=0.0, reps=1):
    npass = 0
    s = sequences.square(1.0, 0.30, period, CYCLES, period / 3)
    for _ in range(reps):
        ns = sequences.add_noise(sequences.mix(s, 0, noise), noise)
        p = fit_period(ns)
        if period - EPS <= p and p <= period + EPS:
            npass += 1
    print "try_square noise {0} period {1} -> {2}%".format(
        noise, period, (100 * npass) / reps)
    return npass
예제 #2
0
def try_square_wave(period, noise=0.0, reps=1):
    npass = 0
    s = sequences.square(1.0, 0.30, period, CYCLES, period // 3)
    for _ in range(reps):
        ns = sequences.add_noise(sequences.mix(s, 0, noise), noise)
        p = fit_period(ns)
        if period - EPS <= p and p <= period + EPS:
            npass += 1
    print("try_square noise {0} period {1} -> {2}%".format(
        noise, period, (100 * npass) / reps))
    return npass
예제 #3
0
def try_sine(period, noise=0.0, reps=1):
    npass = 0
    s = sequences.sine(1.0, period, CYCLES, period // 3)
    for _ in range(reps):
        ns = sequences.add_noise(sequences.mix(s, 0, noise), noise)
        ns = ns - ns.mean()
        p = fit_period(ns)
        if period - EPS <= p and p <= period + EPS:
            npass += 1
    print("try_sine noise {0} period {1} -> {2}%".format(
        noise, period, (100 * npass) / reps))
    return npass
예제 #4
0
def try_sawtooth(period, noise=0.0, reps=1):
    eps = 3 # why is sawtooth so flaky?
    npass = 0
    s = sequences.sawtooth(1.0, period, CYCLES, period / 3)
    for _ in range(reps):
        ns = sequences.add_noise(sequences.mix(s, 0, noise), noise)
        ns = ns - ns.mean()
        p = fit_period(ns)
        if period - eps <= p and p <= period + eps:
            npass += 1
        else:
            print "saw {0} got {1}".format(period, p)
    print "try_sawtooth noise {0} period {1} -> {2}%".format(
        noise, period, (100 * npass) / reps)
    return npass
예제 #5
0
def try_sawtooth(period, noise=0.0, reps=1):
    eps = 3  # why is sawtooth so flaky?
    npass = 0
    s = sequences.sawtooth(1.0, period, CYCLES, period // 3)
    for _ in range(reps):
        ns = sequences.add_noise(sequences.mix(s, 0, noise), noise)
        ns = ns - ns.mean()
        p = fit_period(ns)
        if period - eps <= p and p <= period + eps:
            npass += 1
        else:
            print("saw {0} got {1}".format(period, p))
    print("try_sawtooth noise {0} period {1} -> {2}%".format(
        noise, period, (100 * npass) / reps))
    return npass