Here is a simple function that provides the average value and variance of the rental according to the size of the size specified by the user.
import numpy as np import matplotlib.pyplot as plt window = 10 # make fake data to scan: data = np.random.rand(100,10) # define window function: def sliding_window(data, window): current_pos = 0 left_pos = 0 win_size = window right_pos = left_pos + win_size vdata = [] mdata = [] while current_pos < len(data-win_size): left_pos = current_pos right_pos = left_pos + win_size mean = np.mean(np.var(data[left_pos:right_pos,:], axis=0)) var = np.var(data[left_pos:right_pos,:], axis=0) vdata.append(var) mdata.append(mean) current_pos += 1 return vdata, mdata dvar, dmean = sliding_window(data, window)
The difference of each sample in the data set:
plt.plot(dvar) plt.show()

The average variance throughout the set:
plt.plot(dmean) plt.show()

source share