Skip to content

Commit

Permalink
Updated T test demo
Browse files Browse the repository at this point in the history
git-svn-id: https://pmtk3.googlecode.com/svn/trunk@2838 b6abd7f4-f95b-11de-aa3c-59de0406b4f5
  • Loading branch information
[email protected] committed Apr 25, 2012
1 parent c7f36b1 commit 18749d8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
16 changes: 15 additions & 1 deletion demos/bayesTtestDemo.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,25 @@

% This file is from pmtk3.googlecode.com

%PMTKneedsStatsToolbox tcdf, ttest

z = [ 30.02, 29.99, 30.11, 29.97, 30.01, 29.99];
y = [ 29.89, 29.93, 29.72, 29.98, 30.02, 29.98];

% Method based on posterior distribution
x = z-y;
N = length(x);
t = mean(x)./(std(x)/sqrt(N));
dof = N-1;
probH1 = 1-tcdf(t, dof) % prob mu>0

% Frequentist method
[h,pval] = ttest(x, 0, 0.95, 'right')
assert(approxeq(probH1, pval))

% Method based on Bayes factors
[BF01, probH0] = bayesTtestOneSample(y-z)
%% Compare to web program (slightly different prior)
% Compare to web program (slightly different prior)
% http://pcl.missouri.edu/sites/default/bf/one-sample.php


Expand Down
7 changes: 6 additions & 1 deletion demos/visDirichletGui.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ function visDirichletGui(arg1)

alpha=[ 2 2 2];

%alpha=0.1*ones(1,3);

end

% compute a fine triangulation of 2-simplex
disp('Triangulating...');
res=200;
Expand All @@ -39,7 +43,8 @@ function visDirichletGui(arg1)
pts(counter,:)=p;
tris2d(counter,:)=[u v];
tris(counter,:)=p;
map(counter) = prod(p.^(alpha-1));
%map(counter) = prod(p.^(alpha-1));
map(counter) = exp(dirichletLogprob(alpha, [u v]));
end
end
tris=tris(1:counter,:);
Expand Down

0 comments on commit 18749d8

Please sign in to comment.