Example #1
0
signal = UncorrelatedGaussianNoise()
wave = signal.make_wave(duration=0.5, framerate=11025)
print serial_corr(wave)

# 布朗噪声中,各个值是前一个值与一个随机“步长”的和,我们预期会有强相关性
from thinkdsp import BrownianNoise

signal = BrownianNoise()
wave = signal.make_wave(duration=0.5, framerate=11025)
print serial_corr(wave)

# 粉噪声介于布朗噪声和UU噪声间,我们预期他会是中度相关性
from thinkdsp import PinkNoise

signal = PinkNoise(beta=1)
wave = signal.make_wave(duration=0.5, framerate=11025)
print serial_corr(wave)

# 粉噪参数为beta=0,为不相关噪声,逐步变化到beta=2,为布朗噪声,对
# 应序列相关性从0变化到非常接近于1.

np.random.seed(19)

betas = np.linspace(0, 2, 21)
corrs = []

for beta in betas:
    signal = PinkNoise(beta=beta)
    wave = signal.make_wave(duration=1.0, framerate=11025)
    corr = serial_corr(wave)
Example #2
0
def plot_pink_autocorr(beta, label):
    signal = PinkNoise(beta=beta)
    wave = signal.make_wave(duration=1.0, framerate=10000)
    lags, corrs = autocorr(wave)
    plt.plot(lags, corrs, label=label)
Example #3
0
import sys

sys.path.insert(1, 'dsp-modulo')

import numpy as np
import thinkplot as plt

from thinkdsp import decorate
from thinkdsp import PinkNoise

pendientes = [0.0, 1.5, 2.0]

for pendiente in pendientes:
    senal = PinkNoise(beta=pendiente)
    wave = senal.make_wave(duration=0.5, framerate=22050)
    #wave.write("ruido_rosa.wav")
    #wave.plot()
    #decorate(xlabel="Tiempo", ylabel= "Amplitud")
    #plt.show()

    etiqueta = f'pendiente= {pendiente}'
    espectro = wave.make_spectrum()
    espectro.plot_power(label=etiqueta, alpha=0.5)

loglog = dict(xscale="log", yscale="log")
decorate(xlabel="Frecuencia", ylabel="Poder", **loglog)
plt.show()