numpy: ExercisesΒΆ
Implement a function that takes a
d
dimensional vectorx
returns their Euclidean norm.Hint
The Euclidean norm of a vector is the square root of its dot product with itself.
Implement a function that takes two
d
dimensional vectorsx
andz
and returns their Euclidean distance.Hint
Can you re-use the solution of the previous exercise?
Implement a function that takes a matrix
A
and an integerk
, and returnsA
elevated to thek
th power.Write a Python program that plots the data here:
https://drive.google.com/open?id=0B0wILN942aEVVlk4TS1WaDItVU0
Every row has an experiment ID and a value; there are 10 experiments, and 100 values (rows) per experiment. For each experiment, plot its values as a time series.
The plot the average time series, i.e. the average curve, where the average is taken over all experiments.
Hint
Use
matplotlib.pyplot
and theplot(x, y)
function, as done in the examples above, to plot the ten curves and their mean.Implement the Power Iteration method for finding the largest eigenvalue and eigenvector of a matrix, as described in the first paragraph of:
Check that it matches the results given by the
eig()
method of thelinalg
module.Implement the Gram-Schmidt orthogonalization routine, described here:
Given the iris dataset, compute the covariance matrix of the petal lenght and petal widht for the iris setosa rows.