15.xx - wwj-2017-1117/graph GitHub Wiki
青蛙跳水井,向上跳3步,但又向下滑了2步。
青蛙跳水井,向上跳的步长是step,但又向下滑了X步(X小于step), 假设水井高位H, 问刚好爬出水井需要多少步?
由于刚好跳出去,那么最后一步的步长肯定是step,其他情况下每步只向上爬了(step-X)步,所以刚好跳出需要步数是N
(H - Step)/(step-X) + 1 = N , 例如 (10-3)/(3-2)+1 = 7+1 =8
实战:人工神经网络逼近股票收盘均价V1
import numpy as np import matplotlib.pyplot as plt
y轴表示日期
date = np.linspace(1, 15, 15)
收盘价
endPrice = np.array( [2511.90, 2538.26, 2510.68, 2591.66, 2732.98, 2701.69, 2701.29, 2678.67, 2726.50, 2681.50, 2739.17, 2715.07, 2823.58, 2864.90, 2919.08])
开盘价
startPrice = np.array( [2438.71, 2500.88, 2534.95, 2512.52, 2594.04, 2743.26, 2697.47, 2695.24, 2678.23, 2722.13, 2674.93, 2744.13, 2717.46, 2832.73, 2877.40])
绘图
plt.figure() for i in range(15): # 柱状图 dataOne = np.zeros([2]) dataOne[0] = i dataOne[1] = i priceOne = np.zeros([2]) priceOne[0] = startPrice[i] priceOne[1] = endPrice[i] # 收盘价大于开盘价,用红色 , lw(line-width)设置线宽 if endPrice[i] > startPrice[i]: plt.plot(dataOne, priceOne, 'r', lw=8) else: plt.plot(dataOne, priceOne, 'g', lw=8) pass plt.show()