Beispiel #1
0
def try_zeros(noise=0, reps=1):
    npass = 0
    for _ in range(reps):
        s = sequences.add_noise(np.zeros(1000), noise)
        if fit_period(s) == None:
            npass += 1
    print "try_zeros noise {0} -> {1}%".format(noise, (100 * npass) / reps)
    return npass
Beispiel #2
0
def try_zeros(noise=0, reps=1):
    npass = 0
    for _ in range(reps):
        s = sequences.add_noise(np.zeros(1000), noise)
        if fit_period(s) == None:
            npass += 1
    print("try_zeros noise {0} -> {1}%".format(noise, (100 * npass) / reps))
    return npass
Beispiel #3
0
def try_aperiodic(n, noise=0, reps=1):
    npass = 0
    for _ in range(reps):
        s = sequences.aperiodic(1.0, n)
        s = sequences.add_noise(s, noise)
        s = s - s.mean()
        if fit_period(s) == None:
            npass += 1
    print "try_aperiod noise {0} -> {1}%".format(noise, (100 * npass) / reps)
    return npass
Beispiel #4
0
def try_aperiodic(n, noise=0, reps=1):
    npass = 0
    for _ in range(reps):
        s = sequences.aperiodic(1.0, n)
        s = sequences.add_noise(s, noise)
        s = s - s.mean()
        if fit_period(s) == None:
            npass += 1
    print("try_aperiod noise {0} -> {1}%".format(noise, (100 * npass) / reps))
    return npass
Beispiel #5
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
Beispiel #6
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
Beispiel #7
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
Beispiel #8
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
Beispiel #9
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