Skip to content

Commit 9dd5fc4

Browse files
author
murphyk2
committed
from laptop
1 parent 3121244 commit 9dd5fc4

File tree

6 files changed

+69
-55
lines changed

6 files changed

+69
-55
lines changed

demos/bookDemos/Bayesian_statistics/bayesChangeOfVar.m

Lines changed: 0 additions & 34 deletions
This file was deleted.

demos/bookDemos/Information_theory/miMixedDemo.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
xticklabelRot(data.varNames)
2020
set(gca,'yticklabel', data.varNames);
2121
title('pairwise mutual information in autompg data')
22-
printPmtkFigure('miMixedDemoColor')
22+
printPmtkFigure('miMixedDemoColor2', 'png')
2323

demos/bookDemos/Variational_inference/KLfwdReverseMixGauss.m

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
% bishop-5-4
1+
% Visualize difference between KL(p,q) and KL(q,p) where p is a mix of two
2+
% 2d Gaussians, and q is a single 2d Gaussian
3+
% This is Figure bishop-5-4
4+
5+
%PMTKauthor Cody Severinski
6+
7+
clear all
28

39
mu = [-1,-1; 1,1];
410

@@ -29,23 +35,31 @@
2935

3036
f = f1 + f2;
3137
% (a)
32-
contour(x1,x2,f,'b',4,'linewidth',3);
38+
figure
39+
contour(x1,x2,f); %,'b',4,'linewidth',3);
3340
hold on;
34-
contour(x1,x2,klf,'r',4,'linewidth',3);
41+
contour(x1,x2,klf); %'r',4,'linewidth',3);
3542
hold off;
36-
print('bishop-5-4a.pdf'); close all;
43+
axis square
44+
printPmtkFigure('KLfwd')
45+
%print('bishop-5-4a.pdf'); close all;
3746

3847
% (b)
39-
contour(x1,x2,f,'b',4,'linewidth',3);
48+
figure
49+
contour(x1,x2,f); %,'b',4,'linewidth',3);
4050
hold on;
41-
contour(x1,x2,kll,'r',4,'linewidth',3);
51+
contour(x1,x2,kll); %'r',4,'linewidth',3);
4252
hold off;
43-
print('bishop-5-4b.pdf'); close all;
53+
printPmtkFigure('KLreverse1')
54+
%print('bishop-5-4b.pdf'); close all;
4455

4556
%(c)
46-
contour(x1,x2,f,'b',4,'linewidth',3);
57+
figure
58+
contour(x1,x2,f); %,'b',4,'linewidth',3);
4759
hold on;
48-
contour(x1,x2,klr,'r',4,'linewidth',3);
60+
contour(x1,x2,klr); %,'r',4,'linewidth',3);
4961
hold off;
50-
print('bishop-5-4c.pdf'); close all;
62+
axis equal
63+
printPmtkFigure('KLreverse1')
64+
%print('bishop-5-4c.pdf'); close all;
5165

demos/otherDemos/hmmGaussTest.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
prior.dof = 15;
2222
end
2323

24-
2524
model = hmmFitEm(data, 2, 'gauss', 'verbose', true, 'piPrior', [3 2], ...
26-
'emissionPrior', prior, 'nRandomRestarts', 3)
27-
25+
'emissionPrior', prior, 'nRandomRestarts', 2, 'maxIter', 10)
26+
break
2827

2928
X = hmmSample(model, 200, 10);
30-
m2 = hmmFitEm(X, 5, 'gauss', 'verbose', true);
29+
%m2 = hmmFitEm(X, 5, 'gauss', 'verbose', true);
3130

matlabTools/graphics/printPmtkFigure.m

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
function printPmtkFigure(filename)
2-
% print current figure to specified file in .pdf format
1+
function printPmtkFigure(filename, format)
2+
% print current figure to specified file in .pdf (or other) format
33

44
% This file is from pmtk3.googlecode.com
55

6+
if nargin <2, format = 'pdf'; end
67

78
if false % set to false to turn off printing
89
%printFolder = 'C:\kmurphy\dropbox\PML\Figures\pdfFigures';
910
printFolder = '/Users/kpmurphy/MLbook/Figures/pdfFigures';
10-
pdfcrop;
11-
fname = sprintf('%s/%s.pdf', printFolder, filename);
11+
if strcmpi(format, 'pdf')
12+
pdfcrop;
13+
end
14+
fname = sprintf('%s/%s.%s', printFolder, filename, format);
1215
fprintf('printing to %s\n', fname);
1316
if exist(fname,'file'), delete(fname); end % prevent export_fig from appending
14-
if 1
17+
if 0
1518
%opts = struct('Color', 'rgb', 'Resolution', 1200, 'fontsize', 12);
1619
opts = struct('Color', 'rgb', 'Resolution', 1200);
1720
exportfig(gcf, fname, opts, 'Format', 'pdf' );
1821
else
19-
set(gca,'Color','none')
22+
set(gca,'Color','none') % turn off gray background
2023
set(gcf,'Color','none')
2124
export_fig(fname)
2225
end

python/README.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
11
This is an experimental directory containing translations of a few
22
pmtk3 demos from Matlab to python. Over time, we hope to port
33
more and more functionality.
4+
5+
--------
6+
7+
Below I include some notes based on Kevin Murphy's experience
8+
getting python 2.6 to work on a Mac OS X
9+
(written from the perspective of a matlab user and someone interested
10+
in data analysis/ scientific computing)
11+
12+
- diveintopython.org is a free 300 page book (pdf format) which is not too basic
13+
but not too advanced. Sometimes reading a pdf is easier than reading
14+
many small html pages.
15+
16+
- The site below contains ipython, numpy, scipy and matplotlib all bundled
17+
together for Mac OS X 10.6
18+
http://stronginference.com/scipy-superpack
19+
20+
- The site below sells ($200 per year per user) a bundle of 75 of the
21+
latest packages, focussing on scientific comptuation
22+
http://www.enthought.com/
23+
24+
- to install packages do this:
25+
1. Download setuptools from http://pypi.python.org/pypi/setuptools#downloads
26+
2. sudo sh setuptools-0.6c11-py2.6.egg
27+
3. Stores it in/ Library/Python/2.6/site-packages
28+
4. Run something like this: sudo easy_install-2.6 networkx
29+
30+
- the networkx package (http://networkx.lanl.gov) supports graph
31+
operations.
32+
33+
- to automatically execute a startup file,
34+
put this in your .bashrc
35+
export PYTHONSTARTUP=/Users/kpmurphy/pystart.py

0 commit comments

Comments
 (0)