File size: 726 Bytes
e2b757a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import numpy as np


def calculate_moving_average(scores, window_size):
    # Convert the scores list to a NumPy array for better performance
    scores_array = np.array(scores)

    # Create an array of rolling windows using the np.convolve function
    moving_averages = np.around(
        np.convolve(scores_array, np.ones(window_size) / window_size, mode="valid"), 2
    )

    return list(moving_averages)


def calculate_tendency_slope(scores):
    # Convert the scores list to a NumPy array for better performance
    scores_array = np.array(scores)

    # Calculate the first derivative (slope) of the scores
    derivative = np.around(np.gradient(scores_array), 2)

    return list(derivative)