<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>【python 統計学 t値】タグの記事一覧｜python-manブログ</title>
	<atom:link href="https://python-man.club/tag/python-%e7%b5%b1%e8%a8%88%e5%ad%a6-t%e5%80%a4/feed/" rel="self" type="application/rss+xml" />
	<link>https://python-man.club</link>
	<description>独学者でもpythonでアプリを作れる！</description>
	<lastBuildDate>Fri, 11 Feb 2022 10:32:39 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.2</generator>
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/><atom:link rel="hub" href="https://websubhub.com/hub"/>	<item>
		<title>【pythonで統計学】t値とp値についてわかりやすく解説</title>
		<link>https://python-man.club/t-value/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=t-value</link>
					<comments>https://python-man.club/t-value/#respond</comments>
		
		<dc:creator><![CDATA[syou0445]]></dc:creator>
		<pubDate>Fri, 29 Oct 2021 14:52:47 +0000</pubDate>
				<category><![CDATA[python]]></category>
		<category><![CDATA[統計学]]></category>
		<category><![CDATA[python 統計学 t値]]></category>
		<guid isPermaLink="false">https://python-man.club/?p=436</guid>

					<description><![CDATA[統計検定を行うと出てくるのが「t値」と「p値」です 多くの場合「p値」について理解していれば、研究結果を述べることができるかと思います 私もそうですし、学会や論文なんかでも「p値」のみに言及していることが多いです しかし]]></description>
										<content:encoded><![CDATA[<p>統計検定を行うと出てくるのが<strong>「t値」と「p値」</strong>です</p>
<p>多くの場合「p値」について理解していれば、研究結果を述べることができるかと思います</p>
<p>私もそうですし、学会や論文なんかでも「p値」のみに言及していることが多いです</p>
<p>しかし、統計の勉強を進めていくと「t値」を理解しなければいけないタイミングがやってきます</p>
<p>今回は「p値」のおさらいと「t値」について解説をしていきたいと思います</p>
<p>これまでの「<strong>pythonで統計学</strong>」の一覧はこちらから見ることができるので、そちらも参考にしてください！</p>
<p>https://python-man.club/python_stastics/</p>
<p style="text-align: center;"><strong></p>
<div class="kaisetsu-box5">
<div class="kaisetsu-box5-title">まとめ</div>
<p></strong><br />
<strong>t値は検定統計量の1種で、仮説検定において標本データから計算される標準化された値</strong><br />
<strong>t値の理解にはt分布の理解が必要<br />
</strong><br />
<strong>p値は帰無仮説を棄却する目安</strong><br />
<strong></p>
</div>
<p></strong></p>
<h2>t値とは</h2>
<p><strong>t値は検定統計量の1種で、t検定を行った際に出てきます</strong></p>
<p><strong>そのため「t値」と呼ばれています</strong></p>
<p><strong>マンホイットニーのU検定などをかけても「t値」は出てきません</strong></p>
<p>以下を見比べるとわかります</p>
<img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-438" src="https://python-man.club/wp-content/uploads/2021/10/スクリーンショット-2021-10-28-21.31.39.png" alt="t検定 t値" width="908" height="293" srcset="https://python-man.club/wp-content/uploads/2021/10/スクリーンショット-2021-10-28-21.31.39.png 908w, https://python-man.club/wp-content/uploads/2021/10/スクリーンショット-2021-10-28-21.31.39-300x97.png 300w, https://python-man.club/wp-content/uploads/2021/10/スクリーンショット-2021-10-28-21.31.39-768x248.png 768w, https://python-man.club/wp-content/uploads/2021/10/スクリーンショット-2021-10-28-21.31.39.png 856w" sizes="(max-width: 908px) 100vw, 908px" />
<img decoding="async" class="alignnone wp-image-439 size-full" src="https://python-man.club/wp-content/uploads/2021/10/スクリーンショット-2021-10-28-21.32.07.png" alt="マンホイットニーのU検定" width="854" height="162" />
<p>t値の算出は、</p>
<p><strong><span class="marker2">t値=標本平均-比較対象値/標準誤差</span></strong></p>
<p>で求めることができます</p>
<p>t値が0である場合には標本の結果が帰無仮説と完全に一致することを示していることになります</p>
<p>標本データと帰無仮説との差が増加すれば、t値の絶対値は増加していきます</p>
<p>t値単体ではあまり判断材料にはしません</p>
<p><strong><span class="marker2">ここでt分布という理解が必要になってきます</span></strong></p>
<h3>t分布とは</h3>
<p>t分布とは「<strong>平均𝑥¯の標本分布において，母集団の標準偏差𝜎の代わりに標本標準偏差𝑠′を用いた場合の標準化後の平均𝑥¯が従う確率分布</strong>」です</p>
<p>ざっくりいうと、標準正規分布の代わりになるのが、t分布ということになります</p>
<p>＞＞＞標準正規分布について(&#8230;coming soon&#8230;)</p>
<p>言葉だけではわかりにくいので、実際にt分布をpythonで書いてみたいと思います</p>
<pre class="language-python"><code>import numpy as np
import matplotlib.pyplot as plt
from scipy import stats

# -10 から 10　の区間で200列の一次元配列を作成
x = np.linspace(-10, 10, 200)

# サブプロットを用意
fig, ax = plt.subplots(1, 1)

# 自由度（1, 3, 30）の3つのt分布をプロット
deg_of_freedom = [1, 3, 30]
for k in deg_of_freedom:
    ax.plot(x, stats.t.pdf(x, k), label=r'$k=%i$' % k)

plt.xlim(-10, 10)
plt.ylim(0, 0.4)

plt.legend()
plt.show()</code></pre>
<img decoding="async" class="alignnone size-full wp-image-443" src="https://python-man.club/wp-content/uploads/2021/10/t分布.png" alt="t分布" width="389" height="252" />
<p>kが自由度を表していますが、自由度の値が大きくなるにつれてt分布がシャープになっているのがわかるかと思います</p>
<p><strong>t分布はサンプルサイズが少ない(n=30以下)場合に用いる、と言われています<br />
</strong><br />
サンプルサイズが増えるにつれて、予測される平均値のブレが少なくなるため、シャープになっていきます</p>
<p>次に標準正規分布とt分布を比較してみたいと思います</p>
<pre class="language-python"><code>import numpy as np
import matplotlib.pyplot as plt
from scipy import stats

x = np.linspace(-10, 10, 100)
z = stats.norm.pdf(x, loc=0, scale=1)
for k in range(1, 10, 4):
    t = stats.t.pdf(x, k)
    plt.plot(x, t, label=f'$k=%i$' % k)
plt.plot(x, z, label='std norm', linewidth=3)
plt.legend()</code></pre>
<img decoding="async" class="alignnone size-full wp-image-446" src="https://python-man.club/wp-content/uploads/2021/10/t分布と正規分布.png" alt="t分布と標準正規分布" width="378" height="248" />
<p>太い赤い線が標準正規分布なので、自由度が増加すると、t分布は標準正規分布に近似していくことがわかります</p>
<p>こういった背景があるため、サンプルサイズが増えた場合には、t分布ではなく、標準正規分布を使用してもOKだよね、となります</p>
<h3>t分布から区間推定を行う</h3>
<p>ではt分布から信頼区間を算出したいと思います</p>
<pre class="language-python"><code>import numpy as np
import matplotlib.pyplot as plt
from scipy import stats

x = np.linspace(-5, 5, 100)
left, right = stats.t.interval(0.95, df=2)
t = stats.t.pdf(x, df=2)
plt.plot(x, t)
plt.axvline(left, c='r')
plt.axvline(right, c='r')
print(left, right)

&gt;&gt;&gt;-4.302652729911275 4.302652729911275</code></pre>
<img decoding="async" class="alignnone size-full wp-image-447" src="https://python-man.club/wp-content/uploads/2021/10/t分布信頼区間.png" alt="t分布信頼区間" width="378" height="248" />
<p>信頼区間の幅が結構大きいのがわかるかと思います</p>
<p>自由度が小さい(今回は自由度2)場合には、区間も広くなってしまいます</p>
<p>では、自由度を大きくしてみたいと思います</p>
<pre class="language-python"><code>import numpy as np
import matplotlib.pyplot as plt
from scipy import stats

x = np.linspace(-5, 5, 100)
left, right = stats.t.interval(0.95, df=100)
t = stats.t.pdf(x, df=100)
plt.plot(x, t)
plt.axvline(left, c='r')
plt.axvline(right, c='r')
print(left, right)

&gt;&gt;&gt;-1.9839715184496334 1.9839715184496334</code></pre>
<img decoding="async" class="alignnone size-full wp-image-448" src="https://python-man.club/wp-content/uploads/2021/10/t分布信頼区間-1.png" alt="t分布信頼区間自由度大" width="378" height="248" />
<p>1枚目と2枚目の赤線の間が95%区間です</p>
<p>自由度が大きくなるにつれて、95%区間が狭くなるのがわかるかと思います</p>
<p style="text-align: center;">
<div class="kaisetsu-box5">
<div class="kaisetsu-box5-title">メモ</div>
<p>
<strong>基本的にはt分布を使用することが推奨されています<br />
</strong><br />
<strong>しかし、自由度が高くなる(サンプルサイズが増える)と標準正規分布に近づくため、標準正規分布が使用されます<br />
</strong><br />
<strong>統計ソフトのほとんどが「正規性の検定」で正規分布をしているかを確認しているので、そちらを使うのがいいと思います<br />
</strong><br />
<strong>pythonなどのプログラミング言語で統計をかける場合には、t分布を用いるのがいいのかな、と思います</strong>
</p>
</div>
<h2>p値について</h2>
<p>p値は多くの人が聞いたことのある単語だと思います</p>
<p>帰無仮説を棄却する値ですね</p>
<img decoding="async" class="alignnone size-full wp-image-254" src="https://python-man.club/wp-content/uploads/2021/09/統計学の基本.001.jpeg" alt="統計学の基本" width="960" height="540" srcset="https://python-man.club/wp-content/uploads/2021/09/統計学の基本.001.jpeg 960w, https://python-man.club/wp-content/uploads/2021/09/統計学の基本.001-300x169.jpeg 300w, https://python-man.club/wp-content/uploads/2021/09/統計学の基本.001-768x432.jpeg 768w, https://python-man.club/wp-content/uploads/2021/09/統計学の基本.001-320x180.jpeg 320w, https://python-man.club/wp-content/uploads/2021/09/統計学の基本.001-640x360.jpeg 640w, https://python-man.club/wp-content/uploads/2021/09/統計学の基本.001.jpeg 856w" sizes="(max-width: 960px) 100vw, 960px" />
<p>95%の確率でその事象が生じると仮定した場合に、</p>
<p>5%未満であった場合には「<strong><span class="marker">滅多に起こらないことが起きた(つまり帰無仮説が間違っていたのではないか)</span></strong>」ということで対立仮説を採択することになります</p>
<p>帰無仮説・対立仮説などのややこしい考え方は、背理法が元になっているので、</p>
<p>興味がある方は、背理法について学んでみてください</p>
<div class="booklink-box" style="text-align: left; padding-bottom: 20px; font-size: small; zoom: 1; overflow: hidden;">
<div class="booklink-image" style="float: left; margin: 0 15px 10px 0;"><a href="https://hb.afl.rakuten.co.jp/hgc/18cb6363.e8f8b707.18cb6364.c87e7f42/yomereba_main_202110292343499781?pc=http%3A%2F%2Fbooks.rakuten.co.jp%2Frb%2F16182676%2F%3Fscid%3Daf_ich_link_urltxt%26m%3Dhttp%3A%2F%2Fm.rakuten.co.jp%2Fev%2Fbook%2F" target="_blank" rel="noopener"><img decoding="async" style="border: none;" src="https://thumbnail.image.rakuten.co.jp/@0_mall/book/cabinet/8297/9784000248297.jpg?_ex=200x200" /></a></div>
<div class="booklink-info" style="line-height: 120%; zoom: 1; overflow: hidden;">
<div class="booklink-name" style="margin-bottom: 10px; line-height: 120%;">
<p><a href="https://hb.afl.rakuten.co.jp/hgc/18cb6363.e8f8b707.18cb6364.c87e7f42/yomereba_main_202110292343499781?pc=http%3A%2F%2Fbooks.rakuten.co.jp%2Frb%2F16182676%2F%3Fscid%3Daf_ich_link_urltxt%26m%3Dhttp%3A%2F%2Fm.rakuten.co.jp%2Fev%2Fbook%2F" target="_blank" rel="noopener">まったくゼロからの論理学</a></p>
<div class="booklink-powered-date" style="font-size: 8pt; margin-top: 5px; font-family: verdana; line-height: 120%;">posted with <a href="https://yomereba.com" target="_blank" rel="nofollow noopener">ヨメレバ</a></div>
</div>
<div class="booklink-detail" style="margin-bottom: 5px;">野矢　茂樹 岩波書店 2020年02月28日頃</div>
<div class="booklink-link2" style="margin-top: 10px;">
<div class="shoplinkrakuten" style="display: inline; margin-right: 5px;"><a href="https://hb.afl.rakuten.co.jp/hgc/18cb6363.e8f8b707.18cb6364.c87e7f42/yomereba_main_202110292343499781?pc=http%3A%2F%2Fbooks.rakuten.co.jp%2Frb%2F16182676%2F%3Fscid%3Daf_ich_link_urltxt%26m%3Dhttp%3A%2F%2Fm.rakuten.co.jp%2Fev%2Fbook%2F" target="_blank" rel="noopener">楽天ブックス</a></div>
<div class="shoplinkamazon" style="display: inline; margin-right: 5px;"><a href="https://www.amazon.co.jp/exec/obidos/asin/4000248294/baseball0445-22/" target="_blank" rel="noopener">Amazon</a></div>
<div class="shoplinkkindle" style="display: inline; margin-right: 5px;"><a href="https://www.amazon.co.jp/gp/search?keywords=%E3%81%BE%E3%81%A3%E3%81%9F%E3%81%8F%E3%82%BC%E3%83%AD%E3%81%8B%E3%82%89%E3%81%AE%E8%AB%96%E7%90%86%E5%AD%A6&amp;__mk_ja_JP=%83J%83%5E%83J%83i&amp;url=node%3D2275256051&amp;tag=baseball0445-22" target="_blank" rel="noopener">Kindle</a></div>
</div>
</div>
<div class="booklink-footer" style="clear: left;"></div>
</div>
<img decoding="async" class="alignnone size-full wp-image-450" src="https://python-man.club/wp-content/uploads/2021/10/Figure-2021-10-29-224441.png" alt="正規分布" width="381" height="252" />
<p>95%というのは、緑で塗りつぶしていない部分が該当します</p>
<p>基本的にはこの範囲に事象が入りうるというのが基本になっています</p>
<h2>まとめ</h2>
<ul>
<li><strong>t分布は，平均<span id="MathJax-Element-40-Frame" class="MathJax" tabindex="0"><span id="MathJax-Span-281" class="math"><span id="MathJax-Span-282" class="mrow"><span id="MathJax-Span-283" class="texatom"><span id="MathJax-Span-284" class="mrow"><span id="MathJax-Span-285" class="munderover"><span id="MathJax-Span-286" class="mi">𝑥</span><span id="MathJax-Span-287" class="mo">¯</span></span></span></span></span></span></span>の標本分布において，母集団の標準偏差<span id="MathJax-Element-41-Frame" class="MathJax" tabindex="0"><span id="MathJax-Span-288" class="math"><span id="MathJax-Span-289" class="mrow"><span id="MathJax-Span-290" class="mi">𝜎</span></span></span></span>の代わりに標本標準偏差<span id="MathJax-Element-42-Frame" class="MathJax" tabindex="0"><span id="MathJax-Span-291" class="math"><span id="MathJax-Span-292" class="mrow"><span id="MathJax-Span-293" class="msup"><span id="MathJax-Span-294" class="mi">𝑠</span><span id="MathJax-Span-295" class="mo">′</span></span></span></span></span>を用いた場合の標準化後の平均<span id="MathJax-Element-43-Frame" class="MathJax" tabindex="0"><span id="MathJax-Span-296" class="math"><span id="MathJax-Span-297" class="mrow"><span id="MathJax-Span-298" class="texatom"><span id="MathJax-Span-299" class="mrow"><span id="MathJax-Span-300" class="munderover"><span id="MathJax-Span-301" class="mi">𝑥</span><span id="MathJax-Span-302" class="mo">¯</span></span></span></span></span></span></span>が従う確率分布</strong></li>
<li><strong>t分布は自由度n-1を唯一のパラメータとする確率分布</strong></li>
<li><strong>自由度を大きくすると徐々に標準正規分布に近づく</strong></li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://python-man.club/t-value/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
