x_axis = np.arange(Ndelay, len(prices)) axarr[0, 0].set_title("Ideal delay") axarr[0, 0].plot(x_axis, y_fde[Ndelay:]) axarr[0, 0].plot(x_axis, y_convolution[Ndelay:], 'o', markerfacecolor='none') # b) Box Nbox = 32 lag = 1 y_fde = apply_box_filter(prices, Nbox) h_box = box(Nbox, Nwindow) candidate = np.convolve(prices - prices[0], h_box) + prices[0] y_convolution = candidate[:len(prices)] axarr[0, 1].set_title("Box") axarr[0, 1].plot(y_fde) axarr[0, 1].plot(y_convolution, 'o', markerfacecolor='none') # c) Ema Neff = 32 lag = 1 y_fde = apply_ema_filter(prices, Neff) h_ema = ema(Neff, Nwindow)
impulse_response_direct = delta(Ndelay, Nwindow) axarr[0, 0].set_ylim(0, 1.1) axarr[0, 0].set_title("Ideal delay") axarr[0, 0].plot(impulse_response_fde) axarr[0, 0].plot(impulse_response_direct, 'o', markerfacecolor='none') # b) Box Nbox = 32 lag = 1 impulse = np.zeros(Nwindow) impulse[lag] = 1 candidate = apply_box_filter(impulse, Nbox) impulse_response_fde = candidate[lag:] impulse_response_direct = box(Nbox, Nwindow) axarr[0, 1].set_title("Box") axarr[0, 1].plot(impulse_response_fde) axarr[0, 1].plot(impulse_response_direct, 'o', markerfacecolor='none') # c) Ema Neff = 32 lag = 1 impulse = np.zeros(Nwindow) impulse[lag] = 1
impulse_response_direct = delta(Ndelay, Nwindow) axarr[0, 0].set_ylim(0, 1.1) axarr[0, 0].set_title("Ideal delay") axarr[0, 0].plot(impulse_response_fde) axarr[0, 0].plot(impulse_response_direct, 'o', markerfacecolor='none') # b) Box Nbox = 32 lag = 1 impulse = np.zeros(Nwindow) impulse[lag] = 1 candidate = apply_box_filter(impulse, Nbox) impulse_response_fde = candidate[lag:] impulse_response_direct = box(Nbox, Nwindow) axarr[0, 1].set_title("Box") axarr[0, 1].plot(impulse_response_fde) axarr[0, 1].plot(impulse_response_direct, 'o',markerfacecolor='none') # c) Ema Neff = 32 lag = 1 impulse = np.zeros(Nwindow) impulse[lag] = 1
h_delta = delta(Ndelay, Nwindow) candidate = np.convolve(prices, h_delta) y_convolution = candidate[:len(prices)] x_axis = np.arange(Ndelay, len(prices)) axarr[0, 0].set_title("Ideal delay") axarr[0, 0].plot(x_axis, y_fde[Ndelay:]) axarr[0, 0].plot(x_axis, y_convolution[Ndelay:], 'o', markerfacecolor='none') # b) Box Nbox = 32 lag = 1 y_fde = apply_box_filter(prices, Nbox) h_box = box(Nbox, Nwindow) candidate = np.convolve(prices - prices[0], h_box) + prices[0] y_convolution = candidate[:len(prices)] axarr[0, 1].set_title("Box") axarr[0, 1].plot(y_fde) axarr[0, 1].plot(y_convolution, 'o', markerfacecolor='none') # c) Ema Neff = 32 lag = 1 y_fde = apply_ema_filter(prices, Neff) h_ema = ema(Neff, Nwindow)