Does np.dot automatically transpose vectors?
问题 I am trying to calculate the first and second order moments for a portfolio of stocks (i.e. expected return and standard deviation). expected_returns_annual Out[54]: ticker adj_close CNP 0.091859 F -0.007358 GE 0.095399 TSLA 0.204873 WMT -0.000943 dtype: float64 type(expected_returns_annual) Out[55]: pandas.core.series.Series weights = np.random.random(num_assets) weights /= np.sum(weights) returns = np.dot(expected_returns_annual, weights) So normally the expected return is calculated by (x1