<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Take the following dataset...
$X = [(x_0^{(1)}, x_1^{(1)}), (x_0^{(2)}, x_1^{(2)}), \dots , (x_0^{(n)}, x_1^{(n)})]$ 
$\textbf{x}^{(i)} = (x_0^{(i)}, x_1^{(i)})$
Step1:  Unweighted Mean
Often when refering to the mean of a multidimensional dataset, we are referring to the mean calculated over each dimension. If the mean is intended to be over the entire dataset it is often explicitly stated.
$\mu = \frac{1}{n} \sum\limits_{i=1}^n \textbf{x}^{(i)} = (\bar{x}_0, \bar{x}_1)$
Step2:  To verify...
Step3:  Standard Deviation
This is often understood as the tendency for the data to "deviate" from the mean. In other words, this is how far on average any one element from the dataset will differ from the mean.
$\sigma = \sqrt{ \frac{1}{n} \sum\limits_{i=1}^n ( \textbf{x}^{(i)} - \mu )^2 }$
Step4:  This time we will verify using vectorized code...
Step5:  Variance
Variance is the square of the standard deviation. Therefore we often simply refer to this quantity as $\sigma ^2$. Why not just use standard deviation? This answer has more theoretical origins than I am comfortable explaining right now. I need to look more into this.
$\sigma ^2 = \frac{1}{n} \sum\limits_{i=1}^n ( \textbf{x}^{(i)} - \mu )^2$
Step6:  To verify we will simply square the standard deviation found in the last section
Step7:  Covariance
This is how we begin to understand the relationship between two variables. If the standard deviation and variance are measures of how each element of a dataset vary from the mean, then covariance is a measure of how two datasets vary together.
$\text{COV}(\vec{x}0, \vec{x}_1) = \frac{1}{n} \sum\limits{i=1}^n ( x_0^{(i)} - \mu_0 )( x_1^{(i)} - \mu_1)$
<ASSISTANT_TASK:>
Python Code:
import numpy as np
size = 50
x = np.array((np.random.randint(1,10,size), np.random.randint(1,10,size))).T
print x
Explanation: Take the following dataset...
$X = [(x_0^{(1)}, x_1^{(1)}), (x_0^{(2)}, x_1^{(2)}), \dots , (x_0^{(n)}, x_1^{(n)})]$ 
$\textbf{x}^{(i)} = (x_0^{(i)}, x_1^{(i)})$
End of explanation
mu = np.average(x, 0) # This performs the average over the two main dimensions
mu
Explanation: Unweighted Mean
Often when refering to the mean of a multidimensional dataset, we are referring to the mean calculated over each dimension. If the mean is intended to be over the entire dataset it is often explicitly stated.
$\mu = \frac{1}{n} \sum\limits_{i=1}^n \textbf{x}^{(i)} = (\bar{x}_0, \bar{x}_1)$
End of explanation
x0_bar = 0
x1_bar = 0
for xi in x:
    x0_bar += xi[0]
    x1_bar += xi[1]
x0_bar /= float(size)
x1_bar /= float(size)
np.array((x0_bar, x1_bar))
Explanation: To verify...
End of explanation
sigma = np.std(x, 0) # This performs the standard deviation over the two main dimensions
sigma
Explanation: Standard Deviation
This is often understood as the tendency for the data to "deviate" from the mean. In other words, this is how far on average any one element from the dataset will differ from the mean.
$\sigma = \sqrt{ \frac{1}{n} \sum\limits_{i=1}^n ( \textbf{x}^{(i)} - \mu )^2 }$
End of explanation
sigma2 = np.array([0.0,0.0])
for xi in x:
    sigma2 += np.power(xi - mu, 2)
np.sqrt(sigma2/size)
Explanation: This time we will verify using vectorized code...
End of explanation
np.var(x, 0)
Explanation: Variance
Variance is the square of the standard deviation. Therefore we often simply refer to this quantity as $\sigma ^2$. Why not just use standard deviation? This answer has more theoretical origins than I am comfortable explaining right now. I need to look more into this.
$\sigma ^2 = \frac{1}{n} \sum\limits_{i=1}^n ( \textbf{x}^{(i)} - \mu )^2$
End of explanation
np.power(sigma, 2)
Explanation: To verify we will simply square the standard deviation found in the last section
End of explanation
np.cov(x.T)
np.dot((x-mu).T, x-mu)/size
plt.scatter(x.T[0], x.T[1])
plt.show()
Explanation: Covariance
This is how we begin to understand the relationship between two variables. If the standard deviation and variance are measures of how each element of a dataset vary from the mean, then covariance is a measure of how two datasets vary together.
$\text{COV}(\vec{x}0, \vec{x}_1) = \frac{1}{n} \sum\limits{i=1}^n ( x_0^{(i)} - \mu_0 )( x_1^{(i)} - \mu_1)$
End of explanation
<END_TASK>