-
Notifications
You must be signed in to change notification settings - Fork 0
/
numpy_statistics.py
30 lines (23 loc) · 965 Bytes
/
numpy_statistics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'''In this exercise you are given the time series of a (stationary) quadrotor equipped with a GPS receiver.
Please calculate the statistics with numpy.
Note: you can use the numpy functions mean, var, cov. Use the two parameter version of cov, i.e., to compute
the covariance of two vectors a and b use numpy.cov(a, b). '''
import numpy as np
def compute_means(lat,lon,alt):
# TODO: implement mean computation
mean_lat = np.mean(lat)
mean_lon = np.mean(lon)
mean_alt = np.mean(alt)
return (mean_lat,mean_lon,mean_alt)
def compute_vars(lat,lon,alt):
# TODO: implement variance computation
var_lat = np.var(lat)
var_lon = np.var(lon)
var_alt = np.var(alt)
return (var_lat,var_lon,var_alt)
def compute_cov(lat,lon,alt):
# TODO: implement covariance computation
cov_lat_lon = np.cov(lat,lon)
cov_lon_alt = np.cov(lon,alt)
cov_lat_alt = np.cov(lat,alt)
return (cov_lat_lon,cov_lon_alt,cov_lat_alt)