# [ferret_users] Student's t-test

```Dear Ferreters,
```
I'd like to know if there's a way to run a t-test to compare two datasets (comparing the two means) within Ferret ? Of course, once you have calculated variances and averages of each dataset, you can get the t-value easily, then compare it to critical t-value from probability charts, for the given dof and crit. probability... But if you want to do that for several gridpoints at the same time, it's annoying. I am wondering if there would be a function that returns directly the significance by comparing calculated t-values to critical t-values from probability tables.
```
Thanks,
Pierre
PS :

example :
data1.nc : x1[i=-90:90, j=-180:180, l=20]
data2.nc : x1[i=-90:90, j=-180:180, l=20]
```
let's say 20 July months on the time dimension. You want to test the significance of the difference between two datasets.
```let n1 = 20
let n2 = 20
let variance1 = x1[l=@var]
let variance2 = x2[l=@var]
let avg1 = x1[l=@ave]
let avg2 = x2[l=@ave]

let diffave = avg1-avg2

let tvalue = diffave / (variance1/n1+variance2/n2)^0.5

The function would be like :
let prob = ttest(variance1,variance2,avg1,avg2,n1,n2)
```
and would return the significance ("prob") (i.e the probability of rejecting the null hypothesis "ave1=ave2").
```

```
```begin:vcard
fn:Pierre Sepulchre
n:Sepulchre;Pierre
org:UCSC - Dpt of Earth and Planetary Sciences;Paleoclimate and Climate Change Lab
email;internet:pierrese@xxxxxxxx
title:Postdoc
tel;work:(+001) 831 459 3504
url:http://es.ucsc.edu/~pierre/
version:2.1
end:vcard

```