General update of several files with to do list
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
TITLE: Data Analysis and Machine Learning: Elements of Probability Theory
|
||||
TITLE: Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis
|
||||
AUTHOR: Morten Hjorth-Jensen {copyright, 1999-present|CC BY-NC} at Department of Physics, University of Oslo & Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
|
||||
DATE: today
|
||||
|
||||
!split
|
||||
===== Things to add =====
|
||||
Add general statistic elements (probability theory mainly), assumed knowledge
|
||||
|
||||
|
||||
!split
|
||||
===== Domains and probabilities =====
|
||||
@@ -568,6 +572,14 @@ the binomial distribution we can show that
|
||||
!et
|
||||
!eblock
|
||||
|
||||
|
||||
!split
|
||||
===== Additions to make =====
|
||||
* discuss more sample mean and variance
|
||||
* sample covariance and Bessel's theorem on 1/(n-1) versus 1/n
|
||||
* add more text to covariance matrix and results of codes
|
||||
|
||||
|
||||
!split
|
||||
===== Meet the covariance! =====
|
||||
!bblock
|
||||
@@ -949,6 +961,49 @@ more practically oriented methods like the blocking technique.
|
||||
#add ref here to flybjerg
|
||||
!eblock
|
||||
|
||||
|
||||
!split
|
||||
===== Code to compute the Covariance matrix and the Covariance =====
|
||||
!bc pycod
|
||||
# Importing various packages
|
||||
from math import exp, sqrt
|
||||
from random import random, seed
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# Sample covariance, note the factor 1/(n-1)
|
||||
def covariance(x, y, n):
|
||||
sum = 0.0
|
||||
mean_x = np.mean(x)
|
||||
mean_y = np.mean(y)
|
||||
for i in range(0, n):
|
||||
sum += (x[(i)]-mean_x)*(y[i]-mean_y)
|
||||
return sum/(n-1.)
|
||||
|
||||
n = 100
|
||||
x = np.random.normal(size=n)
|
||||
print(np.mean(x))
|
||||
y = 4+3*x+np.random.normal(size=n)
|
||||
print(np.mean(y))
|
||||
z = x**3+np.random.normal(size=n)
|
||||
print(np.mean(z))
|
||||
covxx = covariance(x,x,n)
|
||||
covyy = covariance(y,y,n)
|
||||
covzz = covariance(z,z,n)
|
||||
covxy = covariance(x,y,n)
|
||||
covxz = covariance(x,z,n)
|
||||
covyz = covariance(y,z,n)
|
||||
print(covxx,covyy, covzz)
|
||||
print(covxy,covxz, covyz)
|
||||
w = np.vstack((x, y, z))
|
||||
#print(w)
|
||||
c = np.cov(w)
|
||||
print(c)
|
||||
#eigen = np.zeros(n)
|
||||
Eigvals, Eigvecs = np.linalg.eig(c)
|
||||
print(Eigvals)
|
||||
!ec
|
||||
|
||||
!split
|
||||
======= Random Numbers =======
|
||||
!bblock
|
||||
|
||||
Reference in New Issue
Block a user