<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def wmean_and_var(W, x):
 """Component-wise weighted mean and variance. Parameters W: (N,) ndarray normalised weights (must be >=0 and sum to one). x: ndarray (such that shape[0]==N) data Returns ------- dictionary {'mean':weighted_means, 'var':weighted_variances} """

    m = np.average(x, weights=W, axis=0)
    m2 = np.average(x**2, weights=W, axis=0)
    v = m2 - m**2
    return {'mean': m, 'var': v}