一標本、二標本、対応のt検定など、あらゆる種類のt検定を実行します。この計算機は、平均値の統計的仮説検定を行い、データ分析と結果の解釈を支援します。
t検定は、グループの平均値に有意な差があるかどうかを判断するための基本的な統計ツールです。これは、心理学、医学、ビジネスなどのさまざまな分野で仮説検定に広く適用されています。この計算機を使用すると、あらゆる種類のt検定を実行できます:
t検定の種類を選択:
必要な入力を入力:
1標本t検定の場合:
2標本t検定の場合:
対応のあるt検定の場合:
有意水準 () を設定:
テストの方向を選択:
「計算」ボタンをクリック:
計算機は以下を表示します:
t検定を使用する前に、以下の仮定が満たされていることを確認してください:
t統計量は次のように計算されます:
プール標準偏差 ():
計算機は以下の手順を実行します:
t検定は強力ですが、常に仮定が満たされるわけではありません。代替手段には以下が含まれます:
t検定は、1908年にウィリアム・シーリー・ゴセットによって開発され、彼はダブリンのギネス醸造所で働いていた際に**「スチューデント」というペンネームで発表しました。この検定は、サンプルバッチが醸造所の基準に一致しているかどうかを判断するためにスタウトの品質を監視するために設計されました。機密保持契約のため、ゴセットは「スチューデント」というペンネームを使用し、これが「スチューデントのt検定」**という用語につながりました。
時が経つにつれ、t検定は統計分析の基盤となり、さまざまな科学分野で広く教えられ、適用されています。これは、より複雑な統計手法の開発への道を開き、推論統計の分野で基本的なものとなっています。
以下は、さまざまなプログラミング言語で1標本t検定を実行するためのコード例です:
1' Excel VBAでの1標本t検定
2Sub OneSampleTTest()
3 Dim sampleData As Range
4 Set sampleData = Range("A1:A9") ' データ範囲を置き換え
5 Dim hypothesizedMean As Double
6 hypothesizedMean = 50 ' 仮定された平均を置き換え
7
8 Dim sampleMean As Double
9 Dim sampleStdDev As Double
10 Dim sampleSize As Integer
11 Dim tStat As Double
12
13 sampleMean = Application.WorksheetFunction.Average(sampleData)
14 sampleStdDev = Application.WorksheetFunction.StDev_S(sampleData)
15 sampleSize = sampleData.Count
16
17 tStat = (sampleMean - hypothesizedMean) / (sampleStdDev / Sqr(sampleSize))
18
19 MsgBox "t統計量: " & Format(tStat, "0.00")
20End Sub
21
1## Rでの1標本t検定
2sample_data <- c(51, 49, 52, 48, 50, 47, 53, 49, 51)
3t_test_result <- t.test(sample_data, mu = 50)
4print(t_test_result)
5
1import numpy as np
2from scipy import stats
3
4## Pythonでの1標本t検定
5sample_data = [51, 49, 52, 48, 50, 47, 53, 49, 51]
6t_statistic, p_value = stats.ttest_1samp(sample_data, 50)
7print(f"t統計量: {t_statistic:.2f}, p値: {p_value:.4f}")
8
1// JavaScriptでの1標本t検定
2function oneSampleTTest(sample, mu0) {
3 const n = sample.length;
4 const mean = sample.reduce((a, b) => a + b) / n;
5 const sd = Math.sqrt(sample.map(x => (x - mean) ** 2).reduce((a, b) => a + b) / (n - 1));
6 const t = (mean - mu0) / (sd / Math.sqrt(n));
7 return t;
8}
9
10// 使用例:
11const sampleData = [51, 49, 52, 48, 50, 47, 53, 49, 51];
12const tStatistic = oneSampleTTest(sampleData, 50);
13console.log(`t統計量: ${tStatistic.toFixed(2)}`);
14
1% MATLABでの1標本t検定
2sampleData = [51, 49, 52, 48, 50, 47, 53, 49, 51];
3[h, p, ci, stats] = ttest(sampleData, 50);
4disp(['t統計量: ', num2str(stats.tstat)]);
5disp(['p値: ', num2str(p)]);
6
1import org.apache.commons.math3.stat.inference.TTest;
2
3public class OneSampleTTest {
4 public static void main(String[] args) {
5 double[] sampleData = {51, 49, 52, 48, 50, 47, 53, 49, 51};
6 TTest tTest = new TTest();
7 double mu = 50;
8 double tStatistic = tTest.t(mu, sampleData);
9 double pValue = tTest.tTest(mu, sampleData);
10 System.out.printf("t統計量: %.2f%n", tStatistic);
11 System.out.printf("p値: %.4f%n", pValue);
12 }
13}
14
1using System;
2using MathNet.Numerics.Statistics;
3
4class OneSampleTTest
5{
6 static void Main()
7 {
8 double[] sampleData = {51, 49, 52, 48, 50, 47, 53, 49, 51};
9 double mu0 = 50;
10 int n = sampleData.Length;
11 double mean = Statistics.Mean(sampleData);
12 double stdDev = Statistics.StandardDeviation(sampleData);
13 double tStatistic = (mean - mu0) / (stdDev / Math.Sqrt(n));
14 Console.WriteLine($"t統計量: {tStatistic:F2}");
15 }
16}
17
1package main
2
3import (
4 "fmt"
5 "math"
6)
7
8func oneSampleTTest(sample []float64, mu0 float64) float64 {
9 n := float64(len(sample))
10 var sum, mean, sd float64
11
12 for _, v := range sample {
13 sum += v
14 }
15 mean = sum / n
16
17 for _, v := range sample {
18 sd += math.Pow(v - mean, 2)
19 }
20 sd = math.Sqrt(sd / (n - 1))
21
22 t := (mean - mu0) / (sd / math.Sqrt(n))
23 return t
24}
25
26func main() {
27 sample_data := []float64{51, 49, 52, 48, 50, 47, 53, 49, 51}
28 tStatistic := oneSampleTTest(sample_data, 50.0)
29 fmt.Printf("t統計量: %.2f\n", tStatistic)
30}
31
1import Foundation
2
3func oneSampleTTest(sample: [Double], mu0: Double) -> Double {
4 let n = Double(sample.count)
5 let mean = sample.reduce(0, +) / n
6 let sd = sqrt(sample.map { pow($0 - mean, 2) }.reduce(0, +) / (n - 1))
7 let t = (mean - mu0) / (sd / sqrt(n))
8 return t
9}
10
11let sampleData = [51, 49, 52, 48, 50, 47, 53, 49, 51]
12let tStatistic = oneSampleTTest(sample: sampleData, mu0: 50)
13print(String(format: "t統計量: %.2f", tStatistic))
14
1<?php
2function oneSampleTTest($sample, $mu0) {
3 $n = count($sample);
4 $mean = array_sum($sample) / $n;
5 $sd = sqrt(array_sum(array_map(function($x) use ($mean) {
6 return pow($x - $mean, 2);
7 }, $sample)) / ($n - 1));
8 $t = ($mean - $mu0) / ($sd / sqrt($n));
9 return $t;
10}
11
12$sampleData = [51, 49, 52, 48, 50, 47, 53, 49, 51];
13$tStatistic = oneSampleTTest($sampleData, 50);
14echo "t統計量: " . number_format($tStatistic, 2);
15?>
16
1## Rubyでの1標本t検定
2def one_sample_t_test(sample, mu0)
3 n = sample.size
4 mean = sample.sum(0.0) / n
5 sd = Math.sqrt(sample.map { |x| (x - mean)**2 }.sum / (n - 1))
6 t = (mean - mu0) / (sd / Math.sqrt(n))
7 t
8end
9
10sample_data = [51, 49, 52, 48, 50, 47, 53, 49, 51]
11t_statistic = one_sample_t_test(sample_data, 50)
12puts format("t統計量: %.2f", t_statistic)
13
1// Rustでの1標本t検定
2fn one_sample_t_test(sample: &Vec<f64>, mu0: f64) -> f64 {
3 let n = sample.len() as f64;
4 let mean: f64 = sample.iter().sum::<f64>() / n;
5 let sd = (sample.iter().map(|x| (x - mean).powi(2)).sum::<f64>() / (n - 1.0)).sqrt();
6 let t = (mean - mu0) / (sd / n.sqrt());
7 t
8}
9
10fn main() {
11 let sample_data = vec![51.0, 49.0, 52.0, 48.0, 50.0, 47.0, 53.0, 49.0, 51.0];
12 let t_statistic = one_sample_t_test(&sample_data, 50.0);
13 println!("t統計量: {:.2}", t_statistic);
14}
15
問題:製造業者は、バッテリーの平均寿命が50時間であると主張しています。消費者団体は9つのバッテリーをテストし、次の寿命(時間)を記録しました:
平均バッテリー寿命が50時間と異なるという証拠が0.05の有意水準であるかどうかを判断します。
解決策:
仮説を立てる:
サンプル平均 () を計算:
サンプル標準偏差 () を計算:
t統計量を計算:
自由度を計算:
p値を決定:
結論: