{"id":12799,"date":"2017-09-01T13:22:20","date_gmt":"2017-09-01T04:22:20","guid":{"rendered":"http:\/\/sitest.jp\/blog\/?p=12799"},"modified":"2017-09-01T13:22:20","modified_gmt":"2017-09-01T04:22:20","slug":"python-%e3%81%a7%e7%b5%b1%e8%a8%88%e5%ad%a6%e5%85%a5%e9%96%80%e2%80%95ab-%e3%83%86%e3%82%b9%e3%83%88%e3%81%ae%e7%b5%b1%e8%a8%88%e7%9a%84%e4%bb%ae%e8%aa%ac%e6%a4%9c%e5%ae%9a%e3%82%92-python-%e3%81%a7","status":"publish","type":"post","link":"https:\/\/sitest.jp\/blog\/?p=12799","title":{"rendered":"Python \u3067\u7d71\u8a08\u5b66\u5165\u9580\u2015AB \u30c6\u30b9\u30c8\u306e\u7d71\u8a08\u7684\u4eee\u8aac\u691c\u5b9a\u3092 Python \u3067\u884c\u3046\u2015"},"content":{"rendered":"<p>AB \u30c6\u30b9\u30c8\u3067\u305d\u308c\u305e\u308c\u306e\u30d1\u30bf\u30fc\u30f3\u306b\u304a\u3044\u3066\u3001\u30b3\u30f3\u30d0\u30fc\u30b8\u30e7\u30f3\u7387\u306a\u3069\u306b\u5dee\u304c\u51fa\u305f\u5834\u5408\u3001<br \/>\n\u305d\u306e\u5dee\u304c\u305f\u307e\u305f\u307e\u306b\u3059\u304e\u306a\u3044\u306e\u304b\u3001\u3069\u3061\u3089\u304b\u306e\u30d1\u30bf\u30fc\u30f3\u3088\u308a\u304c\u3042\u308b\u306e\u304b\u3069\u3046\u304b\u3092\u7d71\u8a08\u7684\u306b\u78ba\u304b\u3081\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u3092\u7d71\u8a08\u7684\u4eee\u8aac\u691c\u5b9a\u3068\u3044\u3044\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/sitest.jp\/blog\/?p=2251\"\u3000target=\"_blank\">\u4ee5\u524d\u306e\u8a18\u4e8b<\/a>\u3067\u306f\u3001\u7d71\u8a08\u7684\u4eee\u8aac\u691c\u5b9a\u306b\u3064\u3044\u3066\u3001\u8a73\u7d30\u306a\u8aac\u660e\u304c\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u3001\u5b9f\u7528\u6027\u3092\u91cd\u8996\u3057\u3001Python \u3092\u4f7f\u3063\u3066\u7c21\u5358\u306b\u305d\u308c\u3092\u6c42\u3081\u3066\u307f\u307e\u3059<br \/>\n<!--more--><\/p>\n<div class=\"frame_headding\">\n<h3 style=\"text-align: left;\">\u30ab\u30a4\u4e8c\u4e57\u691c\u5b9a\u3092 Python \u3067\u884c\u3046<\/h3>\n<\/div>\n<p>\u3055\u3066\u3001AB\u30c6\u30b9\u30c8\u306e\u7d50\u679c\u306b\u3001\u5076\u7136\u3067\u306f\u306a\u3044\u5dee\u304c\u3042\u308b\u304b\u3069\u3046\u304b\u3092\u78ba\u304b\u3081\u308b\u305f\u3081\u306b\u306f\u3001\u7d71\u8a08\u7684\u4eee\u8aac\u691c\u5b9a\u306e\u3046\u3061\u3001\u30ab\u30a4\u4e8c\u4e57\u691c\u5b9a\u3092\u4f7f\u3046\u306e\u304c\u4e00\u822c\u7684\u3067\u3059\u3002<\/p>\n<p>\u4f55\u304b\u96e3\u3057\u305d\u3046\u3067\u3059\u304c\u3001Python \u306e Scipy \u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u3048\u3070\u3001\u7c21\u5358\u306b\u305d\u308c\u3092\u3082\u3068\u3081\u308b\u4e8b\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>Scipy \u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><code>pip install numpy\npip install scipy\n<\/code><\/pre>\n<p>\u3055\u3066\u3001AB \u30c6\u30b9\u30c8\u306e\u7d50\u679c\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u306a\u3063\u305f\u3068\u3057\u307e\u3059<\/p>\n<p><img loading=\"lazy\" src=\"https:\/\/storage.googleapis.com\/sitest-wp\/blog\/wp-content\/uploads\/2017\/08\/Blog-11-300x114.jpg\" alt=\"\" width=\"300\" height=\"114\" class=\"alignnone size-medium wp-image-12800\" \/><\/p>\n<div class=\"frame_headding\">\n<h3 style=\"text-align: left;\">\u5b9f\u969b\u306e\u30b3\u30fc\u30c9<\/h3>\n<\/div>\n<p>\u3053\u306e\u7d50\u679c\u306b\u5bfe\u3057\u30ab\u30a4\u4e8c\u4e57\u691c\u5b9a\u3092\u884c\u3046\u30b3\u30fc\u30c9\u306f\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code># coding: UTF-8\nimport numpy as np\nfrom scipy import stats\n\n#\u30b3\u30f3\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u3042\u3063\u305f\u30af\u30ea\u30c3\u30af\/\u306a\u304b\u3063\u305f\u30af\u30ea\u30c3\u30af\u30922\u6b21\u5143\u8868\u3067\u8868\u3057\u307e\u3059\u3002\ndata = np.array([[400, 9600],[340, 9660]])\ng, p, dof, expctd=stats.chi2_contingency(data)\nprint(\"\u03c7\uff12\u4e57\u5024\u306f %(g)s\"%locals())\nprint( \"\u78ba\u7387\u306f %(p)s\" %locals() )\n#2\u3064\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u5dee\u304c\u5076\u7136\u306b\u8d77\u3053\u308a\u5f97\u308b\u53ef\u80fd\u6027\u304c5%\u4ee5\u4e0b\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\nif p &lt; 0.05:\n    print(\"\u6709\u610f\u306a\u5dee\u304c\u3042\u308a\u307e\u3059\")\nelse:\n    print(\"\u6709\u610f\u306a\u5dee\u304c\u3042\u308a\u307e\u305b\u3093\")\n\n<\/code><\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059<\/p>\n<pre><code>\u03c7\uff12\u4e57\u5024\u306f 4.88479133339\n\u78ba\u7387\u306f 0.0270943093864\n\u6709\u610f\u306a\u5dee\u304c\u3042\u308a\u307e\u3059\n<\/code><\/pre>\n<p>\u3059\u3067\u306b\u96c6\u8a08\u6e08\u307f\u306e\u30c7\u30fc\u30bf\u3067\u3042\u308b\u306e\u3067 scipy.stats \u306b\u3042\u308b\u3082\u306e\u306e\u5185\u3001chi2_contingency \u30e1\u30bd\u30c3\u30c9\u3092\u7528\u3044\u307e\u3059\u3002\u4e0e\u3048\u308b\u30c7\u30fc\u30bf\u306f\u3001\u305d\u308c\u305e\u308c\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u7d50\u679c\u30922\u6b21\u5143\u914d\u5217\uff08numpy\uff09\u306b\u3057\u305f\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u3055\u3066\u30014\u7a2e\u985e\u306e\u6570\u5024\u304c chi2_contingency \u30e1\u30bd\u30c3\u30c9\u306e\u623b\u308a\u5024\u304c\u5f97\u3089\u308c\u307e\u3059\u304c\u3001\u6700\u3082\u91cd\u8981\u306a\u3082\u306e\u304c p\u5024=\u78ba\u7387 \u3067\u3059\u30021\u304c100%\u3068\u3057\u3066\u3001\u7d50\u679c\u306e\u5dee\u304c\u5076\u7136\u3067\u3042\u308b\u78ba\u7387\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u5834\u5408\u3001\u3053\u306e\u7d50\u679c\u304c\u5076\u7136\u3067\u3042\u308b\u78ba\u7387\u304c\u3001\u7d040.027\u3001\u3059\u306a\u308f\u3061\u30012.7%\u3067\u3042\u308b\u306e\u3067\u3001\u300c\u3053\u306e\u7d50\u679c\u306f\u5076\u7136\u3067\u306f\u306a\u3044=\u6709\u610f\u3067\u3042\u308b\u300d\u3068\u3044\u3046\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u4f55%\u4ee5\u4e0b\u3092\u6709\u610f\u3068\u8a8d\u3081\u308b\u306e\u304c\u6b63\u3057\u3044\u306e\u3067\u3057\u3087\u3046\u304b\uff1f\u53b3\u5bc6\u306a\u30c6\u30b9\u30c8\u306e\u5834\u5408\u30011%\u4ee5\u4e0b\u3067\u7121\u3044\u3068\u3044\u3051\u306a\u3044\u3002\u3068\u3044\u3046\u5224\u65ad\u3082\u3067\u304d\u307e\u3059\u304c\u3001AB\u30c6\u30b9\u30c8\u306e\u5834\u5408\u3001\u6570\u5343\u3001\u6570\u4e07\u306e\u30b5\u30f3\u30d7\u30eb\u304c\u5f97\u3089\u308c\u308b\u5834\u5408\u306a\u3089\u30015%\u4ee5\u4e0b\u3001\u30b5\u30f3\u30d7\u30eb\u6570\u304c\u3059\u304f\u306a\u3051\u308c\u307010%\u4ee5\u4e0b\u3067\u3001\u300c\u610f\u5473\u306e\u3042\u308b\u9055\u3044\u300d\u3068\u307f\u306a\u3059\u5834\u5408\u304c\u591a\u3044\u3067\u3059\u3002<\/p>\n<p>Python \u3092\u4f7f\u3048\u3070\u3001\u5c02\u9580\u7684\u77e5\u8b58\u304c\u5fc5\u8981\u306a\u8a08\u7b97\u3082\u304b\u306a\u308a\u7c21\u5358\u306b\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u306e\u3067\u3001\u305c\u3072\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>AB \u30c6\u30b9\u30c8\u3067\u305d\u308c\u305e\u308c\u306e\u30d1\u30bf\u30fc\u30f3\u306b\u304a\u3044\u3066\u3001\u30b3\u30f3\u30d0\u30fc\u30b8\u30e7\u30f3\u7387\u306a\u3069\u306b\u5dee\u304c\u51fa\u305f\u5834\u5408\u3001 \u305d\u306e\u5dee\u304c\u305f\u307e\u305f\u307e\u306b\u3059\u304e\u306a\u3044\u306e\u304b\u3001\u3069\u3061\u3089\u304b\u306e\u30d1\u30bf\u30fc\u30f3\u3088\u308a\u304c\u3042\u308b\u306e\u304b\u3069\u3046\u304b\u3092\u7d71\u8a08\u7684\u306b\u78ba\u304b\u3081\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u3092\u7d71\u8a08\u7684\u4eee\u8aac\u691c\u5b9a\u3068\u3044\u3044\u307e\u3059\u3002 \u4ee5\u524d\u306e\u8a18\u4e8b\u3067\u306f\u3001\u7d71\u8a08\u7684\u4eee\u8aac\u691c\u5b9a\u306b\u3064\u3044\u3066\u3001\u8a73\u7d30\u306a\u8aac\u660e\u304c\u3055\u308c\u3066\u3044\u307e\u3059\u3002 \u4eca\u56de\u306f\u3001\u5b9f\u7528\u6027\u3092\u91cd\u8996\u3057\u3001Python \u3092\u4f7f\u3063\u3066\u7c21\u5358\u306b\u305d\u308c\u3092\u6c42\u3081\u3066\u307f\u307e\u3059<\/p>\n","protected":false},"author":1,"featured_media":12801,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,27],"tags":[],"acf":false,"_links":{"self":[{"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/posts\/12799"}],"collection":[{"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/comments?post=12799"}],"version-history":[{"count":5,"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/posts\/12799\/revisions"}],"predecessor-version":[{"id":12902,"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/posts\/12799\/revisions\/12902"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/media\/12801"}],"wp:attachment":[{"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/media?parent=12799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/categories?post=12799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/tags?post=12799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}