Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uva
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
uva
Commits
c35ec4b5
Commit
c35ec4b5
authored
14 years ago
by
Sander Mathijs van Veen
Browse files
Options
Downloads
Patches
Plain Diff
StatRed: completed question 21.
parent
183196e1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
statred/ass1/q21-multivariate.py
+44
-0
44 additions, 0 deletions
statred/ass1/q21-multivariate.py
with
44 additions
and
0 deletions
statred/ass1/q21-multivariate.py
0 → 100644
+
44
−
0
View file @
c35ec4b5
from
pylab
import
array
,
eig
,
diagflat
,
dot
,
sqrt
,
randn
,
tile
from
pylab
import
plot
,
axis
,
show
,
figure
,
clf
mean
=
array
([[
3
],
[
4
],
[
5
],
[
6
]])
cov
=
array
(
[[
3.01602775
,
1.02746769
,
-
3.60224613
,
-
2.08792829
],
[
1.02746769
,
5.65146472
,
-
3.98616664
,
0.48723704
],
[
-
3.60224613
,
-
3.98616664
,
13.04508284
,
-
1.59255406
],
[
-
2.08792829
,
0.48723704
,
-
1.59255406
,
8.28742469
]])
samples
=
1000
vector_size
=
4
figure
(
1
)
clf
()
d
,
U
=
eig
(
cov
)
L
=
diagflat
(
d
)
A
=
dot
(
U
,
sqrt
(
L
))
X
=
randn
(
vector_size
,
samples
)
Y
=
dot
(
A
,
X
)
+
tile
(
mean
,
samples
)
#import matplotlib.pyplot as plt
for
i
in
range
(
4
):
for
j
in
range
(
4
):
if
i
!=
j
:
plot
(
Y
[
i
],
Y
[
j
],
'
x
'
)
axis
(
'
equal
'
)
#plt.plot(x,y,'x');
#plt.axis('equal');
#plt.show()
show
()
#import numpy as np
#x,y = np.random.multivariate_normal(mean, cov, 5000).T
#print 'x:', x
#print 'y:', y
#plt.plot(x,y,'x'); plt.axis('equal'); plt.show()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment