Function Repository Resource:

StudentTValue

Source Notebook

Calculate the Student's t-value that corrects for the bias of the unknown standard deviation in the statistical uncertainty of a measurement

Contributed by: Julien Kluge

ResourceFunction["StudentTValue"][ν]

calculates the Student's t-value for a StudentTDistribution with ν degrees of freedom.

ResourceFunction["StudentTValue"][ν,Around[value,error]]

returns the Around expression with error scaled by Student’s t with ν degrees of freedom.

ResourceFunction["StudentTValue"][ν,{Around[v1,e1],Around[v2,e2],}]

returns a list of Around expressions.

ResourceFunction["StudentTValue"][{v1,v2,}]

returns an Around created as by MeanAround with an error scaled by the Student’s t-value.

Details and Options

The degrees of freedom parameter ν must be a positive integer.
Use of this function is recommeded when a statistical measurement has less than 20 data points.
ResourceFunction["StudentTValue"] takes the option ConfidenceLevel.

Examples

Basic Examples (3) 

Calculate the Student’s t-value for two degrees of freedom:

In[1]:=
ResourceFunction["StudentTValue"][6]
Out[1]=

Scale the error of an around by the Student’s t-value:

In[2]:=
ResourceFunction["StudentTValue"][6, Around[1.00, 0.20]]
Out[2]=

Calculate the value of a measurement with a Student’s t-value scaled error:

In[3]:=
ResourceFunction["StudentTValue"][{1, 2, 3, 4, 3, 2, 1}]
Out[3]=

Scope (3) 

The function can return an exact value in the single argument form. Use N to get a numerical value:

In[4]:=
stu = ResourceFunction["StudentTValue"][2]
Out[4]=
In[5]:=
N[stu]
Out[5]=

The function can handle a list of Around values:

In[6]:=
test = ResourceFunction["StudentTValue"][
  6, {Around[1.00, 0.20], Around[2.00, 0.30], Around[3.00, 0.40]}]
Out[6]=

StudentTValue can handle asymmetric Around:

In[7]:=
ResourceFunction["StudentTValue"][6, Around[1.00, {0.20, 0.30}]]
Out[7]=

Options (1) 

StudentTValue will calculate the Student’s t-value according to the specified ConfidenceLevel (which is per default at 0.683=1σ):

In[8]:=
ResourceFunction["StudentTValue"][20, ConfidenceLevel -> 0.95]
Out[8]=

Applications (1) 

Calculate the statistical uncertainty for measurements with only a few data points:

In[9]:=
data = RandomVariate[NormalDistribution[1, 1], 6];
ResourceFunction["StudentTValue"][data]
Out[10]=

Properties and Relations (2) 

The Student’s t-value for a List is equal to the Student’s t-value of the resulting MeanAround of the data with the degrees of freedom equal to the number of data points minus one:

In[11]:=
ResourceFunction["StudentTValue"][{1, 2, 3, 4, 3, 2, 1}] === ResourceFunction["StudentTValue"][7 - 1, MeanAround[{1, 2, 3, 4, 3, 2, 1}]]
Out[11]=

For many measurements, StudentTValue will tend towards one (if the ConfidenceLevel option is set to Automatic as default):

In[12]:=
DiscretePlot[
 ResourceFunction["StudentTValue"][\[Nu]], {\[Nu], 1, 100}, PlotRange -> All]
Out[12]=

Possible Issues (2) 

The function only accepts integers as the degree of freedom parameter ν:

In[13]:=
ResourceFunction["StudentTValue"][1.0]
Out[13]=

The function returns an infinitely-big error interval for just one value:

In[14]:=
ResourceFunction["StudentTValue"][{1}]
Out[14]=

Neat Examples (1) 

The error interval from StudentTValue always encloses the one from MeanAround but converges for a high enough number of measurements:

In[15]:=
list = RandomVariate[NormalDistribution[1, 0.2], 20];
ListPlot[
 Transpose[({ResourceFunction["StudentTValue"][#], MeanAround[#]} &@
      list[[1 ;; #]]) & /@ Range[2, Length[list]]], IntervalMarkers -> "Bands", PlotRange -> {{0, 20}, {0.8, 1.2}}]
Out[16]=

Publisher

Julien Kluge

Version History

  • 1.0.0 – 21 April 2020

Related Resources

Author Notes

This function could be built into MeanAround as an option.
Julien Kluge Quantum Optical Metrology; Joint Lab Integrated Quantum Sensors Department of Physics Humboldt-Universität zu Berlin julien@physik.hu-berlin.de

License Information