T-Test Calculator
Introduction
t-test એ એક મૂળભૂત આંકડાકીય સાધન છે જે જૂથોની સરેરાશ વચ્ચે મહત્વપૂર્ણ તફાવત છે કે કેમ તે નિર્ધારિત કરવા માટે ઉપયોગમાં લેવાય છે. આનું વ્યાપક રીતે માનસશાસ્ત્ર, મેડિસિન અને બિઝનેસ જેવા વિવિધ ક્ષેત્રોમાં હિપોથિસિસ ટેસ્ટિંગ માટે ઉપયોગ થાય છે. આ કેલ્ક્યુલેટર તમને તમામ પ્રકારના t-ટેસ્ટ કરવા દે છે:
- One-Sample T-Test: એક જ જૂથની સરેરાશ જાણીતું મૂલ્યથી અલગ છે કે કેમ તે પરીક્ષણ કરે છે.
- Two-Sample T-Test (Independent Samples): બે સ્વતંત્ર જૂથોની સરેરાશની તુલના કરે છે.
- Paired T-Test: અલગ અલગ સમય પર (ઉદાહરણ તરીકે, સારવાર પહેલાં અને પછી) સમાન જૂથમાંથી સરેરાશની તુલના કરે છે.
Types of T-Tests
How to Use This Calculator
-
Select the Type of T-Test:
- One-Sample T-Test
- Two-Sample T-Test
- Paired T-Test
-
Enter the Required Inputs:
-
For One-Sample T-Test:
- Sample Mean ()
- Sample Standard Deviation ()
- Sample Size ()
- Population Mean ()
-
For Two-Sample T-Test:
- Mean of Sample 1 ()
- Standard Deviation of Sample 1 ()
- Sample Size of Sample 1 ()
- Mean of Sample 2 ()
- Standard Deviation of Sample 2 ()
- Sample Size of Sample 2 ()
- Variance Assumption: Variances સમાન કે અસમાન છે તે પસંદ કરો.
-
For Paired T-Test:
- Differences Data: પેરવાઈઝ તફાવત દાખલ કરો.
- વૈકલ્પિક રીતે, Mean of Differences (), Standard Deviation of Differences (), અને Sample Size () દાખલ કરો.
-
-
Set the Significance Level ():
- સામાન્ય પસંદગીઓ 0.05 95% વિશ્વાસ સ્તર માટે અથવા 0.01 99% વિશ્વાસ સ્તર માટે છે.
-
Choose the Test Direction:
- Two-Tailed Test: કોઈ તફાવત માટે પરીક્ષણ કરે છે.
- One-Tailed Test: દિશાત્મક તફાવત માટે પરીક્ષણ કરે છે (મહત્વપૂર્ણ છે કે તે વધુ કે ઓછું પરીક્ષણ કરે છે).
-
Click the "Calculate" Button:
-
કેલ્ક્યુલેટર દર્શાવશે:
- T-Statistic
- Degrees of Freedom
- P-Value
- Conclusion: નલ હિપોથિસિસને રદ કરવા કે ન કરવા માટે.
-
Assumptions
t-testનો ઉપયોગ કરતા પહેલા, ખાતરી કરો કે નીચેની ધારણાઓ પૂરી થાય છે:
- Normality: ડેટા લગભગ સામાન્ય રીતે વિતરણમાં હોવું જોઈએ.
- Independence: અવલોકનો એકબીજાથી સ્વતંત્ર હોવા જોઈએ.
- Two-Sample T-Test માટે, બે જૂથો સ્વતંત્ર હોવા જોઈએ.
- Paired T-Test માટે, તફાવત સ્વતંત્ર હોવા જોઈએ.
- Equality of Variances:
- Two-Sample T-Test with Equal Variances માટે, બે જનસાંખ્યાઓની વેરિયન્સ સમાન હોવી જોઈએ (હોમોસ્કેડાસ્ટિસિટી).
- જો આ ધારણા પૂરી ન થાય, તો Welch's T-Test (અસમાન વેરિયન્સ) નો ઉપયોગ કરો.
Formula
One-Sample T-Test
t-સાંખ્યિકી નીચે મુજબ ગણવામાં આવે છે:
- : નમૂનાનો સરેરાશ
- : નલ હિપોથિસિસ હેઠળની જનસાંખ્યાનો સરેરાશ
- : નમૂનાનો સ્ટાન્ડર્ડ ડેવિયેશન
- : નમૂનાની કદ
Two-Sample T-Test (Independent Samples)
Equal Variances Assumed
Pooled standard deviation ():
Unequal Variances (Welch's T-Test)
Paired T-Test
- : તફાવતનો સરેરાશ
- : તફાવતનો સ્ટાન્ડર્ડ ડેવિયેશન
- : જોડીઓની સંખ્યા
Degrees of Freedom
One-Sample and Paired T-Test:
Two-Sample T-Test with Equal Variances:
Welch's T-Test:
Calculation
કેલ્ક્યુલેટર નીચેના પગલાં કરે છે:
- T-Statistic ની ગણતરી કરો પસંદ કરેલ પરીક્ષણ આધારિત યોગ્ય સૂત્રનો ઉપયોગ કરીને.
- Degrees of Freedom (df) નક્કી કરો.
- P-Value ની ગણતરી કરો t-સાંખ્યિકી અને df માટે:
- ત-વિતરણનો ઉપયોગ કરીને સંભાવના શોધે છે.
- P-Value ને Significance Level () સાથે તુલના કરો:
- જો , તો નલ હિપોથિસિસને રદ કરો.
- જો , તો નલ હિપોથિસિસને રદ ન કરો.
- પરિણામોને અર્થ આપો:
- પરીક્ષણના સંદર્ભમાં નિષ્કર્ષ પ્રદાન કરો.
Use Cases
One-Sample T-Test
- નવી દવા કાર્યક્ષમતા પરીક્ષણ:
- જાણીતું સરેરાશ પુનઃપ્રાપ્તિ સમયથી નવા દવાઓ સાથે સરેરાશ પુનઃપ્રાપ્તિ સમય જુદા છે કે નહીં તે નિર્ધારિત કરો.
- ગુણવત્તા નિયંત્રણ:
- બનાવેલ ભાગોની સરેરાશ લંબાઈ નિર્ધારિત ધોરણથી અલગ છે કે નહીં તે તપાસો.
Two-Sample T-Test
- માર્કેટિંગમાં A/B પરીક્ષણ:
- બે અલગ વેબ પૃષ્ઠ ડિઝાઇન વચ્ચે રૂપાંતરણ દરોની તુલના કરો.
- શૈક્ષણિક સંશોધન:
- બે શિક્ષણ પદ્ધતિઓ વચ્ચે પરીક્ષા સ્કોરમાં તફાવત છે કે નહીં તે મૂલ્યાંકન કરો.
Paired T-Test
- પહેલાં અને પછીના અભ્યાસ:
- આહાર કાર્યક્રમ પહેલાં અને પછી વજન ઘટાડો મૂલ્યાંકન કરો.
- મેચ કરેલા વિષયો:
- સમાન વિષયોને દવા આપ્યા પછી બ્લડ પ્રેશર માપનની તુલના કરો.
Alternatives
જ્યારે t-tests શક્તિશાળી હોય છે, ત્યારે તેમની ધારણાઓ હંમેશા પૂરી ન થઈ શકે. વિકલ્પોમાં સમાવેશ થાય છે:
- Mann-Whitney U Test:
- જ્યારે ડેટા સામાન્ય વિતરણને અનુસરે છે ત્યારે બે-નમૂનાના t-test માટે નોન-પેરામેટ્રિક વિકલ્પ.
- Wilcoxon Signed-Rank Test:
- Paired t-test માટે નોન-પેરામેટ્રિક સમકક્ષ.
- ANOVA (Analysis of Variance):
- જ્યારે બે કરતાં વધુ જૂથો વચ્ચે સરેરાશોની તુલના માટે ઉપયોગમાં લેવાય છે.
History
t-test નું વિકાસ William Sealy Gosset દ્વારા 1908 માં કરવામાં આવ્યું હતું, જેમણે "Student" ઉપનામ હેઠળ પ્રકાશિત કર્યું જ્યારે તેઓ ડબ્લિનમાં ગુનેસ બિયરે કામ કરી રહ્યા હતા. આ પરીક્ષણ stout ની ગુણવત્તાને મોનિટર કરવા માટે રચાયેલ હતું જેથી નમૂનાના બેચો બિયરની ધોરણો સાથે સુસંગત છે કે કેમ તે નિર્ધારિત કરવા માટે. ગુપ્તતાના કરારોના કારણે, ગોસેટે "વિદ્યાર્થી" ઉપનામનો ઉપયોગ કર્યો, જેના પરિણામે "Student's t-test." શબ્દનો ઉપયોગ થયો.
સમય સાથે, t-test આંકડાશાસ્ત્રીય વિશ્લેષણમાં એક ખૂણાકાર બની ગયો, જે વિવિધ વૈજ્ઞાનિક શાખાઓમાં વ્યાપક રીતે શીખવવામાં અને લાગુ કરવામાં આવે છે. તે વધુ જટિલ આંકડાશાસ્ત્ર પદ્ધતિઓના વિકાસના માર્ગે આવ્યું અને આંકડાશાસ્ત્રના ક્ષેત્રમાં મૂળભૂત છે.
Examples
અહીં વિવિધ પ્રોગ્રામિંગ ભાષાઓમાં One-Sample T-Test કરવા માટેના કોડ ઉદાહરણો છે:
Excel
' One-Sample T-Test in Excel VBA
Sub OneSampleTTest()
Dim sampleData As Range
Set sampleData = Range("A1:A9") ' Replace with your data range
Dim hypothesizedMean As Double
hypothesizedMean = 50 ' Replace with your hypothesized mean
Dim sampleMean As Double
Dim sampleStdDev As Double
Dim sampleSize As Integer
Dim tStat As Double
sampleMean = Application.WorksheetFunction.Average(sampleData)
sampleStdDev = Application.WorksheetFunction.StDev_S(sampleData)
sampleSize = sampleData.Count
tStat = (sampleMean - hypothesizedMean) / (sampleStdDev / Sqr(sampleSize))
MsgBox "T-Statistic: " & Format(tStat, "0.00")
End Sub
R
## One-Sample T-Test in R
sample_data <- c(51, 49, 52, 48, 50, 47, 53, 49, 51)
t_test_result <- t.test(sample_data, mu = 50)
print(t_test_result)
Python
import numpy as np
from scipy import stats
## One-Sample T-Test in Python
sample_data = [51, 49, 52, 48, 50, 47, 53, 49, 51]
t_statistic, p_value = stats.ttest_1samp(sample_data, 50)
print(f"T-Statistic: {t_statistic:.2f}, P-Value: {p_value:.4f}")
JavaScript
// One-Sample T-Test in JavaScript
function oneSampleTTest(sample, mu0) {
const n = sample.length;
const mean = sample.reduce((a, b) => a + b) / n;
const sd = Math.sqrt(sample.map(x => (x - mean) ** 2).reduce((a, b) => a + b) / (n - 1));
const t = (mean - mu0) / (sd / Math.sqrt(n));
return t;
}
// Example usage:
const sampleData = [51, 49, 52, 48, 50, 47, 53, 49, 51];
const tStatistic = oneSampleTTest(sampleData, 50);
console.log(`T-Statistic: ${tStatistic.toFixed(2)}`);
MATLAB
% One-Sample T-Test in MATLAB
sampleData = [51, 49, 52, 48, 50, 47, 53, 49, 51];
[h, p, ci, stats] = ttest(sampleData, 50);
disp(['T-Statistic: ', num2str(stats.tstat)]);
disp(['P-Value: ', num2str(p)]);
Java
import org.apache.commons.math3.stat.inference.TTest;
public class OneSampleTTest {
public static void main(String[] args) {
double[] sampleData = {51, 49, 52, 48, 50, 47, 53, 49, 51};
TTest tTest = new TTest();
double mu = 50;
double tStatistic = tTest.t(mu, sampleData);
double pValue = tTest.tTest(mu, sampleData);
System.out.printf("T-Statistic: %.2f%n", tStatistic);
System.out.printf("P-Value: %.4f%n", pValue);
}
}
C#
using System;
using MathNet.Numerics.Statistics;
class OneSampleTTest
{
static void Main()
{
double[] sampleData = {51, 49, 52, 48, 50, 47, 53, 49, 51};
double mu0 = 50;
int n = sampleData.Length;
double mean = Statistics.Mean(sampleData);
double stdDev = Statistics.StandardDeviation(sampleData);
double tStatistic = (mean - mu0) / (stdDev / Math.Sqrt(n));
Console.WriteLine($"T-Statistic: {tStatistic:F2}");
}
}
Go
package main
import (
"fmt"
"math"
)
func oneSampleTTest(sample []float64, mu0 float64) float64 {
n := float64(len(sample))
var sum, mean, sd float64
for _, v := range sample {
sum += v
}
mean = sum / n
for _, v := range sample {
sd += math.Pow(v - mean, 2)
}
sd = math.Sqrt(sd / (n - 1))
t := (mean - mu0) / (sd / math.Sqrt(n))
return t
}
func main() {
sampleData := []float64{51, 49, 52, 48, 50, 47, 53, 49, 51}
tStatistic := oneSampleTTest(sampleData, 50)
fmt.Printf("T-Statistic: %.2f\n", tStatistic)
}
Swift
import Foundation
func oneSampleTTest(sample: [Double], mu0: Double) -> Double {
let n = Double(sample.count)
let mean = sample.reduce(0, +) / n
let sd = sqrt(sample.map { pow($0 - mean, 2) }.reduce(0, +) / (n - 1))
let t = (mean - mu0) / (sd / sqrt(n))
return t
}
let sampleData = [51, 49, 52, 48, 50, 47, 53, 49, 51]
let tStatistic = oneSampleTTest(sample: sampleData, mu0: 50)
print(String(format: "T-Statistic: %.2f", tStatistic))
PHP
<?php
function oneSampleTTest($sample, $mu0) {
$n = count($sample);
$mean = array_sum($sample) / $n;
$sd = sqrt(array_sum(array_map(function($x) use ($mean) {
return pow($x - $mean, 2);
}, $sample)) / ($n - 1));
$t = ($mean - $mu0) / ($sd / sqrt($n));
return $t;
}
$sampleData = [51, 49, 52, 48, 50, 47, 53, 49, 51];
$tStatistic = oneSampleTTest($sampleData, 50);
echo "T-Statistic: " . number_format($tStatistic, 2);
?>
Ruby
## One-Sample T-Test in Ruby
def one_sample_t_test(sample, mu0)
n = sample.size
mean = sample.sum(0.0) / n
sd = Math.sqrt(sample.map { |x| (x - mean)**2 }.sum / (n - 1))
t = (mean - mu0) / (sd / Math.sqrt(n))
t
end
sample_data = [51, 49, 52, 48, 50, 47, 53, 49, 51]
t_statistic = one_sample_t_test(sample_data, 50)
puts format("T-Statistic: %.2f", t_statistic)
Rust
// One-Sample T-Test in Rust
fn one_sample_t_test(sample: &Vec<f64>, mu0: f64) -> f64 {
let n = sample.len() as f64;
let mean: f64 = sample.iter().sum::<f64>() / n;
let sd = (sample.iter().map(|x| (x - mean).powi(2)).sum::<f64>() / (n - 1.0)).sqrt();
let t = (mean - mu0) / (sd / n.sqrt());
t
}
fn main() {
let sample_data = vec![51.0, 49.0, 52.0, 48.0, 50.0, 47.0, 53.0, 49.0, 51.0];
let t_statistic = one_sample_t_test(&sample_data, 50.0);
println!("T-Statistic: {:.2}", t_statistic);
}
Numerical Example
Problem: એક ઉત્પાદક દાવો કરે છે કે એક બેટરીની સરેરાશ જીવનકાળ 50 કલાક છે. એક ગ્રાહક જૂથ 9 બેટરીઓનું પરીક્ષણ કરે છે અને નીચેના જીવનકાળ (કલાકમાં) નોંધે છે:
શું 0.05 મહત્વપૂર્ણ સ્તરે એ સૂચવે છે કે સરેરાશ બેટરી જીવનકાળ 50 કલાકથી અલગ છે?
Solution:
-
Hypotheses ની રાજ્ય:
- Null Hypothesis ():
- Alternative Hypothesis ():
-
Sample Mean () ની ગણતરી:
-
Sample Standard Deviation () ની ગણતરી:
-
T-Statistic ની ગણતરી:
-
Degrees of Freedom:
-
P-Value ની નિર્ધારણા:
- અને માટે, p-value 1.00 છે.
-
Conclusion:
- કારણ કે p-value (1.00) > (0.05), અમે નલ હિપોથિસિસને રદ ન કરીએ.
- Interpretation: સરેરાશ બેટરી જીવનકાળ 50 કલાકથી અલગ છે તે સૂચવવા માટે પૂરતી પુરાવા નથી.
References
- Gosset, W. S. (1908). "The Probable Error of a Mean". Biometrika, 6(1), 1–25. JSTOR.
- Student's t-test. Wikipedia. https://en.wikipedia.org/wiki/Student%27s_t-test
- GraphPad Statistics Guide: Understanding t-tests. Link
- Laerd Statistics: Independent t-test. Link
Additional Resources
- Assumption Checks:
- Shapiro-Wilk Test નો ઉપયોગ કરીને સામાન્યતા માટે.
- Levene's Test નો ઉપયોગ કરીને વેરિયન્સની સમાનતા માટે.
- Software Tools:
- SPSS, SAS, Stata, અને R માટે અદ્યતન આંકડાશાસ્ત્રીય વિશ્લેષણ.
- Further Reading:
- "Introduction to Statistical Learning" by Gareth James, Daniela Witten, Trevor Hastie, and Robert Tibshirani.
- "Statistical Methods" by George W. Snedecor and William G. Cochran.