tinv
Student's t inverse cumulative distribution function
Syntax
Description
Examples
Compute Student's t icdf
Find the 95th percentile of the Student's t distribution with 50
degrees of freedom.
p = .95; nu = 50; x = tinv(p,nu)
x = 1.6759
Compute Student's t icdf for Multiple Distributions
Compute the 99th percentile of the Student's t distribution for 1
to 6
degrees of freedom.
percentile = tinv(0.99,1:6)
percentile = 1×6
31.8205 6.9646 4.5407 3.7469 3.3649 3.1427
Compute Confidence Interval Using Student's t icdf
Find a 95% confidence interval estimating the mean of a population by using tinv
.
Generate a random sample of size 100
drawn from a normal population with mean 10
and standard deviation 2
.
mu = 10; sigma = 2; n = 100; rng default % For reproducibility x = normrnd(mu,sigma,n,1);
Compute the sample mean, standard error, and degrees of freedom.
xbar = mean(x); se = std(x)/sqrt(n); nu = n - 1;
Find the upper and lower confidence bounds for the 95%
confidence interval.
conf = 0.95; alpha = 1 - conf; pLo = alpha/2; pUp = 1 - alpha/2;
Compute the critical values for the confidence bounds.
crit = tinv([pLo pUp], nu);
Determine the confidence interval for the population mean.
ci = xbar + crit*se
ci = 1×2
9.7849 10.7075
This confidence interval is the same as the ci
value returned by a t
test of a null hypothesis that the sample comes from a normal population with mean mu
.
[h,p,ci2] = ttest(x,mu,'Alpha',alpha);
ci2
ci2 = 2×1
9.7849
10.7075
Input Arguments
p
— Probability values at which to evaluate icdf
scalar value in [0,1]
| array of scalar values
Probability values at which to evaluate the icdf, specified as a scalar value or an
array of scalar values, where each element is in the range
[0,1]
.
To evaluate the icdf at multiple values, specify
p
using an array.To evaluate the icdfs of multiple distributions, specify
nu
using an array.
If either or both of the input arguments p
and
nu
are arrays, then the array sizes must be the same. In this case,
tinv
expands each scalar input into a constant array of the same
size as the array inputs. Each element in x
is the icdf value of the
distribution specified by the corresponding element in nu
, evaluated at the
corresponding probability in p
.
Example: [0.1 0.5 0.9]
Data Types: single
| double
nu
— Degrees of freedom
positive scalar value | array of positive scalar values
Degrees of freedom for the Student's t distribution, specified as a positive scalar value or an array of positive scalar values.
To evaluate the icdf at multiple values, specify
p
using an array.To evaluate the icdfs of multiple distributions, specify
nu
using an array.
If either or both of the input arguments p
and
nu
are arrays, then the array sizes must be the same. In this case,
tinv
expands each scalar input into a constant array of the same
size as the array inputs. Each element in x
is the icdf value of the
distribution specified by the corresponding element in nu
, evaluated at the
corresponding probability in p
.
Example: [9 19 49 99]
Data Types: single
| double
Output Arguments
x
— icdf values
scalar value | array of scalar values
icdf values evaluated at the probabilities in p
, returned as a
scalar value or an array of scalar values. x
is the same size as
p
and nu
after any necessary scalar
expansion. Each element in x
is the icdf value of the
distribution specified by the corresponding element in nu
, evaluated at the
corresponding probability in p
.
More About
Student’s t icdf
The Student's t distribution is a one-parameter family of curves. The parameter ν is the degrees of freedom. The Student's t distribution has zero mean.
The t inverse function is defined in terms of the Student's t cdf as
where
ν is the degrees of freedom, and Γ( · ) is the Gamma function. The result x is the solution of the integral equation where you supply the probability p.
For more information, see Student's t Distribution.
Alternative Functionality
tinv
is a function specific to the Student's t distribution. Statistics and Machine Learning Toolbox™ also offers the generic functionicdf
, which supports various probability distributions. To useicdf
, specify the probability distribution name and its parameters. Note that the distribution-specific functiontinv
is faster than the generic functionicdf
.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced before R2006a
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)