File size: 469 Bytes
a57c6eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from typing import List
import numpy as np


def weighted_sum(weights: List[float], datas: List[np.array]) -> np.array:
    """ε―ΉηŸ©ι˜΅εˆ—θ‘¨ζŒ‰η…§ζƒι‡εˆ—θ‘¨εŠ ζƒζ±‚ε’Œ

    Args:
        weights (list): ζƒι‡εˆ—θ‘¨
        datas (list): ηŸ©ι˜΅εˆ—θ‘¨

    Returns:
        np.array: εŠ ζƒζ±‚ε’ŒεŽηš„ηŸ©ι˜΅
    """
    res = np.zeros(datas[0].shape)
    n_data = len(datas)
    for i in range(n_data):
        res += datas[i] * weights[i] / n_data
    return res