I downloaded Matlab recently for my project but cannot do z test and t test. Is there any tutorial (video) for it?

5 views (last 30 days)
I downloaded Matlab recently for my project but cannot do z test and t test. Is there any tutorial (video) for it

Answers (1)

Star Strider
Star Strider on 23 Nov 2015
You have to have the Statistics Toolbox to have full access to these tests. However, if you do not have the Statistics Toolbox, a description of the tests can be found in Wikipedia, and the test statistics are easy to code. The t-distribution and its inverse is also easy to code using core MATLAB functions:
% Variables:
% t: t-statistic
% v: degrees of freedom
tdist2T = @(t,v) (1-betainc(v/(v+t^2),v/2,0.5)); % 2-tailed t-distribution
tdist1T = @(t,v) 1-(1-tdist2T(t,v))/2; % 1-tailed t-distribution
% These calculate the inverse t-distribution (parameters given the
% probability ‘alpha’ and degrees of freedom ‘v’:
tstat = @(tval) (alpha - tdist2T(tval,df) ); % Function to calculate t-statistic for p = ‘alpha’ and v = ‘degrees-of-freedom’
[T,fval] = fzero(tstat, 1); % Calculate t-statistic for p = ‘alpha’ and v = ‘degrees-of-freedom’
See the documentation on the core MATLAB function erf for instructions on how to use it to calculate the normal distribution and its inverse.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!