Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
uva
Commits
bae9b637
Commit
bae9b637
authored
Apr 12, 2011
by
Sander Mathijs van Veen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
StatRed: added comments to q22.
parent
96dd3447
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
5 deletions
+21
-5
statred/ass1/Makefile
statred/ass1/Makefile
+6
-0
statred/ass1/q22_estimate.py
statred/ass1/q22_estimate.py
+15
-5
No files found.
statred/ass1/Makefile
0 → 100644
View file @
bae9b637
.PHONY
:
all clean
all
:
clean
:
rm
-vf
*
.pyc q
*
.pdf
statred/ass1/q22_estimate.py
View file @
bae9b637
from
q21_multivariate
import
dataset
from
numpy
import
array
,
mean
,
tile
,
newaxis
,
dot
from
pylab
import
eigvals
,
axis
,
figure
,
clf
,
show
,
plot
from
pylab
import
array
,
mean
,
tile
,
newaxis
,
dot
,
eigvals
,
\
axis
,
figure
,
clf
,
show
,
plot
def
eigenvalues
(
n
):
"""Return eigenvalues of unbiased estimators for the covariance matrix
Sigma (based on a pseudo-random generated dataset)."""
Y
=
array
([
mean
(
dataset
(),
1
)
for
i
in
range
(
n
)]).
T
# Sigma = 1 / (n - 1) * Sum for i=1 to n: (x_i - x_mean) T(x_i - x_mean),
# where T(x) is the transpose of `x'. Mu = x_mean and
# Yzm = Sum for i=1 to n: x_i - x_mean.
mu
=
mean
(
Y
,
1
)
Yzm
=
Y
-
tile
(
mu
[:,
newaxis
],
n
)
S
=
dot
(
Yzm
,
Yzm
.
T
)
/
(
n
-
1
)
...
...
@@ -11,14 +18,17 @@ def eigenvalues(n):
figure
(
1
)
clf
()
samples
=
range
(
2
,
10000
,
500
)
max_range
=
10000
samples
=
range
(
2
,
max_range
,
500
)
data
=
[[]
for
i
in
range
(
4
)]
for
n
in
samples
:
e
=
eigenvalues
(
n
)
for
i
in
range
(
4
):
data
[
i
].
append
(
e
[
i
])
for
i
in
range
(
4
):
#subplot(2, 2, i+1)
plot
(
samples
,
data
[
i
],
'x'
)
axis
([
0
,
10000
,
0.
,
0.025
])
axis
([
0
,
max_range
,
0.
,
0.025
])
show
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment