Module RelayModel.ConceptChange
Expand source code
import math
import statistics
def calculate_windows(window_a, window_b):
"""Calculates a change rate of two given windows provided as lists.
The two lists should be of same size.
Args:
window_a (list): Holds the first window
window_b (list): Holds the second window
Returns:
int: A change rate of the both windows
"""
mean_a = statistics.mean(window_a)
mean_b = statistics.mean(window_b)
var_a = statistics.variance(window_a, mean_a)
var_b = statistics.variance(window_b, mean_b)
frac_a = 1.0/len(window_a)
frac_b = 1.0/len(window_b)
divider = math.sqrt(frac_a*var_a + frac_b*var_b)
if divider != 0:
result = mean_a - mean_b
result = result / divider
else:
result = 0
return result
Functions
def calculate_windows(window_a, window_b)-
Calculates a change rate of two given windows provided as lists.
The two lists should be of same size.
Args
window_a:list- Holds the first window
window_b:list- Holds the second window
Returns
int- A change rate of the both windows
Expand source code
def calculate_windows(window_a, window_b): """Calculates a change rate of two given windows provided as lists. The two lists should be of same size. Args: window_a (list): Holds the first window window_b (list): Holds the second window Returns: int: A change rate of the both windows """ mean_a = statistics.mean(window_a) mean_b = statistics.mean(window_b) var_a = statistics.variance(window_a, mean_a) var_b = statistics.variance(window_b, mean_b) frac_a = 1.0/len(window_a) frac_b = 1.0/len(window_b) divider = math.sqrt(frac_a*var_a + frac_b*var_b) if divider != 0: result = mean_a - mean_b result = result / divider else: result = 0 return result