This question already has an answer here:

I'm trying to do a Welch's t-test of two sample groups which turn to have estimated variance equal to 0.

As could be seen from wikipedia page of Welch's t-test: https://en.wikipedia.org/wiki/Welch%27s_t-test, the formula for calculating the t-stat:

$$ t= \frac{\overline X_1 - \overline X_2}{\sqrt{\frac{s_1^2}{N_1} +\frac{s_2^2}{N_2}}} $$ contains 0 at the denominator and the t-stat could not be calculated (obviously my C++ program retuns me a NaN value...)

I need a way to handle this an calculate the t-test anyway, could you tell me how to proceed in these cases?


marked as duplicate by whuber Sep 26 '16 at 17:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ What do mean by handling the t-test? $\endgroup$ – Ian_Fin Sep 26 '16 at 17:12
  • $\begingroup$ I mean that I need to calculate the t statistic anyway in order to do the t-test $\endgroup$ – Alessio Martorana Sep 26 '16 at 17:15
  • $\begingroup$ If the variance is zero, then all the values are identical -- is it true? $\endgroup$ – Tim Sep 26 '16 at 17:16
  • $\begingroup$ In my data I've found very similar samples, but not identical... $\endgroup$ – Alessio Martorana Sep 26 '16 at 17:19
  • $\begingroup$ Also see stats.stackexchange.com/questions/86618. $\endgroup$ – whuber Sep 26 '16 at 17:38

I need a way to handle this an calculate the t-test anyway

You can't. t is undefined. See here.


Not the answer you're looking for? Browse other questions tagged or ask your own question.