{"id":310,"date":"2019-06-09T23:14:45","date_gmt":"2019-06-09T14:14:45","guid":{"rendered":"https:\/\/obenkyolab.com\/?p=310"},"modified":"2020-05-19T22:56:51","modified_gmt":"2020-05-19T13:56:51","slug":"python%e3%81%a7%e7%b5%b1%e8%a8%88%e5%ad%a6%e5%8b%89%e5%bc%b7%e3%80%80%e8%aa%bf%e5%92%8c%e5%b9%b3%e5%9d%87%e3%81%a8%e7%b5%b6%e5%af%be%e5%b9%b3%e5%9d%87","status":"publish","type":"post","link":"https:\/\/obenkyolab.com\/?p=310","title":{"rendered":"\u3010Python\u3011\u3067\u8abf\u548c\u5e73\u5747\u3068\u7d76\u5bfe\u5e73\u5747\u8a08\u7b97"},"content":{"rendered":"\n\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/obenkyolab.com\/?p=310\/#%E7%9B%AE%E7%9A%84\" >\u76ee\u7684<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/obenkyolab.com\/?p=310\/#%E8%AA%BF%E5%92%8C%E5%B9%B3%E5%9D%87\" >\u8abf\u548c\u5e73\u5747<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/obenkyolab.com\/?p=310\/#%E7%B5%B6%E5%AF%BE%E5%B9%B3%E5%9D%87\" >\u7d76\u5bfe\u5e73\u5747<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%9B%AE%E7%9A%84\"><\/span>\u76ee\u7684<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u524d\u56de\u3001\u4e00\u822c\u7684\u306b\u5e73\u5747\u3068\u3057\u3066\u4f7f\u308f\u308c\u308b\u7b97\u8853\u5e73\u5747\u306b\u52a0\u3048\u3001\u25cb\u25cb\u7387\u306e\u5e73\u5747\u306a\u3069\u306e\u8a08\u7b97\u306b\u5411\u3044\u3066\u3044\u308b\u5e7e\u4f55\u5e73\u5747\u306e\u5b9a\u7fa9\u3068\u8a08\u7b97\u65b9\u6cd5\u306b\u3064\u3044\u3066\u52c9\u5f37\u3057\u307e\u3057\u305f\u3002<br> \u4eca\u56de\u306f\u3001\u3055\u3089\u306b\u305d\u308c\u4ee5\u5916\u306e\u5e73\u5747\u306e\u8003\u3048\u65b9\u3067\u3042\u308b\u8abf\u548c\u5e73\u5747\u3068\u7d76\u5bfe\u5e73\u5747\u306b\u3064\u3044\u3066\u3082\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u306a\u304c\u3089\u52c9\u5f37\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%AA%BF%E5%92%8C%E5%B9%B3%E5%9D%87\"><\/span>\u8abf\u548c\u5e73\u5747<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>A\u541b\u3068B\u541b\u304c\u3044\u307e\u3059\u3002\u8ddd\u96e2\\(2L\\)[km]\u3092\u4e8c\u4eba\u3067\u5747\u7b49\u306b\u5206\u3051\u3066\u8d70\u308b\u3053\u3068\u306b\u3057\u3001A\u541b\u304c\\(L\\)[km]\u3001B\u541b\u3082\\(L\\)[km]\u8d70\u308b\u3053\u3068\u306b\u3057\u305f\u3068\u3057\u307e\u3059\u3002<br>\u305f\u3060\u3057\u3001A\u541b\u3068B\u541b\u306e\u8d70\u308b\u901f\u3055\u306f\u9055\u3046\u3082\u306e\u3068\u3057\u307e\u3059\u3002<br>\u3064\u307e\u308a\u3001A\u541b\u306f\u6642\u901f\\(a\\)[km]\u3001B\u541b\u306f\u6642\u523b\\(b\\)[km]\u3067\u8d70\u308a\u307e\u3059\u3002<br>\u3053\u306e\u6642\u3001\u4e8c\u4eba\u306e\u8d70\u308b\u901f\u3055\u306e\u5e73\u5747\u306f\u3044\u304f\u3064\u306b\u306a\u308b\u304b\uff1f<br><br>\u3053\u306e\u3088\u3046\u306a\u554f\u984c\u3092\u8003\u3048\u308b\u3068\u304d\u306b<strong>\u8abf\u548c\u5e73\u5747<\/strong>\u3068\u3044\u3046\u8003\u3048\u65b9\u3092\u4f7f\u3044\u307e\u3059\u3002<br><br>\u304c\u3001\u307e\u305a\u306f\u666e\u901a\u306e\u5e73\u5747\u3067\u3042\u308b\u5358\u7d14\u306a\u7b97\u8853\u5e73\u5747\u3092\u4f7f\u3063\u305f\u5834\u5408\u306e\u8a08\u7b97\u3092\u8003\u3048\u3066\u307f\u307e\u3059\u3002\u4ee5\u4e0b\u3067\u8a08\u7b97\u3067\u304d\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>$$\\frac{a+b}{2}$$<\/p>\n\n\n\n<p><br>\u3057\u304b\u3057\u3001\u3053\u308c\u306f\u6b63\u3057\u3044\u3067\u3057\u3087\u3046\u304b\u30fb\u30fb\u30fb\uff1f<br><br><strong>\u7d50\u8ad6\u304b\u3089\u3044\u3046\u3068\u6b63\u3057\u3044\u3068\u306f\u8a00\u3048\u307e\u305b\u3093\u3002<\/strong><br>\u7406\u7531\u306f\u5225\u306e\u8003\u3048\u65b9\u3092\u3057\u3066\u307f\u308b\u3068\u5206\u304b\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>A\u541b\u304c\\(L\\)[km]\u8d70\u308b\u306e\u306b\u304b\u304b\u308b\u6642\u9593\u306f\\(L\/a\\)[h]\u3001B\u541b\u304c\\(L\\)[km]\u8d70\u308b\u306e\u306b\u304b\u304b\u308b\u6642\u9593\u306f\\(L\/b\\)[h]\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u4e8c\u4eba\u3067\\(2L\\)[km]\u8d70\u308b\u306e\u306b\u304b\u304b\u308b\u6642\u9593\u306f<\/p>\n\n\n\n<p>$$\\frac{L}{a}+ \\frac{L}{b}$$<\/p>\n\n\n\n<p>\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u3057\u3066\u3001\u4e8c\u4eba\u3067\u8d70\u3063\u305f\u8ddd\u96e2\u306e\u5408\u8a08\u306f\\(2L\\)[km]\u3067\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u5e73\u5747\u901f\u3055\u3092\u8a08\u7b97\u3059\u308b\u3068\u4ee5\u4e0b\u306b\u306a\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n\n\n\n<p>$$  2L \\div\\left(\\frac{L}{a}+ \\frac{L}{b }\\right)  = \\frac{1}{\\frac{1}{2}(\\frac{1}{a}+\\frac{1}{b})}$$<\/p>\n\n\n\n<p>\u4e0a\u8a18\u304b\u3089\u308f\u304b\u308b\u3088\u3046\u306b\u3001\u5e73\u5747\u901f\u5ea6\u306f\u4e8c\u4eba\u306e\u8d70\u308b\u901f\u5ea6\u306e\u9006\u6570\u306e\u5e73\u5747\u306e\u3055\u3089\u306b\u9006\u6570\u3092\u3068\u3063\u305f\u3082\u306e\u306b\u306a\u308a\u307e\u3059\u3002<br>\u3053\u306e\u3088\u3046\u306a\u8003\u3048\u65b9\u3067\u8a08\u7b97\u3055\u308c\u305f\u5e73\u5747\u3092\u8abf\u548c\u5e73\u5747\u3068\u547c\u3073\u307e\u3059<br>\u305d\u3057\u3066\u3001\u3053\u308c\u306f\u7b97\u8853\u5e73\u5747\u306e\u8a08\u7b97\u5f0f\u3068\u7570\u306a\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p><br>\u3067\u306f\u4e21\u8005\u306e\u8003\u3048\u65b9\u306e\u9055\u3044\u3068\u306f\u4f55\u3067\u3057\u3087\u3046\u304b\u3002<br><br>\u7b97\u8853\u5e73\u5747\u3067\u306fA\u541b\u306e\u901f\u3055\\(a\\)\u3068B\u541b\u306e\u901f\u3055\\(b\\)\u3092\u8db3\u3057\u30662\u3067\u5272\u3063\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306f\u8a00\u3046\u306a\u308c\u3070\u3001\u901f\u3055\\(\\frac{a+b}{2}\\)\u3068\u3044\u3046\u901f\u3055\u306eC\u541b\u3092\u65b0\u305f\u306b\u5b9a\u7fa9\u3057\u3066\u3001C\u541b\u306b\\(2L\\)\u3092\u8d70\u3089\u305b\u308b\u3068\u3044\u3046\u3088\u3046\u306a\u8003\u3048\u65b9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4e00\u65b9\u8abf\u548c\u5e73\u5747\u306e\u8a08\u7b97\u306fA\u541b\u3068B\u541b\u306e\u6240\u8981\u6642\u9593\u3092\u305d\u308c\u305e\u308c\u8a08\u7b97\u3057\u3001\u8ddd\u96e2\u00f7\u6642\u9593\u3068\u3044\u3046\u901f\u3055\u306e\u57fa\u672c\u5f0f\u306b\u3088\u3063\u3066\u7b97\u51fa\u3059\u308b\u8003\u3048\u65b9\u3067\u3059\u3002<br><br><br>\u5e73\u5747\u901f\u3055\u3092\u77e5\u308a\u305f\u3044\u3001\u3068\u3044\u3046\u5834\u5408\u306b\u4e0a\u8a18\u306e\uff12\u3064\u306e\u3046\u3061\u3069\u3061\u3089\u306e\u8003\u3048\u65b9\u306e\u7b54\u3048\u3092\u77e5\u308a\u305f\u3044\u304b\u3001\u3068\u3044\u3046\u3068\u5f8c\u8005\u306e\u8003\u3048\u65b9\u3067\u5c0e\u304b\u308c\u305f\u7b54\u3048\u306e\u307b\u3046\u304c\u81ea\u7136\u304b\u3068\u601d\u3044\u307e\u3059\u3002<br>\u3053\u308c\u304c\u8abf\u548c\u5e73\u5747\u306e\u7528\u9014\u3067\u3059\u3002<br><br><\/p>\n\n\n\n<p>\u3067\u306f\u5b9f\u969b\u306bpython\u3067\u8a08\u7b97\u3057\u3066\u307f\u307e\u3059\u3002<br>\u4e0a\u8a18\u306e\u4f8b\u3067\u3001A\u541b\u6642\u901f7[km]\u3001B\u541b\u6642\u901f10[km]\u3068\u3057\u305f\u969b\u306e\u901f\u3055\u306e\u5e73\u5747\u306b\u3064\u3044\u3066\u3001\u7b97\u8853\u5e73\u5747\u3068\u8abf\u548c\u5e73\u5747\u3092\u305d\u308c\u305e\u308c\u6c42\u3081\u307e\u3059\u3002\u30b3\u30fc\u30c9\u3068\u3057\u3066\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5f62\u3067\u8a18\u8ff0\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy as np\nfrom scipy import stats\n\nprint(&#039;\u7b97\u8853\u5e73\u5747:&#039;,np.mean(&#x5B;&#x5B;7, 10]])) #\u7b97\u8853\u5e73\u5747: 8.5\nprint(&#039;\u8abf\u548c\u5e73\u5747\uff1a&#039;,stats.hmean(&#x5B;7, 10])) #\u8abf\u548c\u5e73\u5747\uff1a 8.23529411764706\n<\/pre><\/div>\n\n\n<p>\u3053\u306e\u4f8b\u3067\u306f\u7b97\u8853\u5e73\u5747\u3088\u308a\u8abf\u548c\u5e73\u5747\u306e\u307b\u3046\u304c\u5c11\u3057\u5c0f\u3055\u3044\u5024\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%B5%B6%E5%AF%BE%E5%B9%B3%E5%9D%87\"><\/span>\u7d76\u5bfe\u5e73\u5747<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u7d76\u5bfe\u5e73\u5747\u306f\u5358\u7d14\u3067\u3059\u3002\u7b97\u8853\u5e73\u5747\u306e\u3088\u3046\u306b\u8db3\u3057\u7b97\u3057\u3066\u6570\u3067\u5272\u308b\u306e\u3067\u3059\u304c\u3001\u8db3\u3057\u3053\u3080\u5024\u306b\u7d76\u5bfe\u5024\u3092\u4f7f\u3046\u306e\u304c\u7d76\u5bfe\u5e73\u5747\u3067\u3059\u3002<br>\u7528\u9014\u3068\u3057\u3066\u306f\u3001\u8aa4\u5dee\u3092\u5e73\u5747\u3059\u308b\u3088\u3046\u306a\u5834\u5408\u3067\u3059\u3002\u7b97\u8853\u5e73\u5747\u3060\u3068\u8aa4\u5dee\u306e\u7b26\u53f7\u306e\u6b63\u8ca0\u3067\u5024\u304c\u6253\u3061\u6d88\u3057\u5408\u3063\u3066\u3057\u307e\u3046\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u7d76\u5bfe\u5e73\u5747\u3092\u4f7f\u3046\u5834\u5408\u304c\u591a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>python\u3060\u3068\u6b21\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3067\u8a08\u7b97\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy as np\n\nx = np.array(&#x5B;-3,2,3,4,6,5,9,4])\nabs_m = abs(x).mean()\nm = x.mean()\nprint(&#039;\u7d76\u5bfe\u5e73\u5747\uff1a&#039;,abs_m) #\u7d76\u5bfe\u5e73\u5747\uff1a 4.5\nprint(&#039;\u7b97\u8853\u5e73\u5747\uff1a&#039;,m)\u3000#\u7b97\u8853\u5e73\u5747\uff1a 3.75\n<\/pre><\/div>\n\n\n<p>\u307e\u305f\u3001python\u306b\u3088\u308b\u8a08\u7b97\u65b9\u6cd5\u3068\u3057\u3066\u3001\u76f4\u63a5\u7684\u306b\u7d76\u5bfe\u5024\u3092\u8a08\u7b97\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u4e8c\u4e57\u5e73\u65b9\u6839\u306e\u5e73\u5747\u5024\u3068\u3057\u3066\u8a08\u7b97\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<br>\u3053\u306e\u4e8c\u4e57\u5e73\u65b9\u6839\u306e\u5e73\u5747\u5024\u306fRMS\u3068\u547c\u3070\u308c\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nRMS = np.sqrt(x*x).mean()\nprint(&#039;RMS\uff1a&#039;,RMS)\u3000#RMS\uff1a 4.5\n<\/pre><\/div>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u7684 \u524d\u56de\u3001\u4e00\u822c\u7684\u306b\u5e73\u5747\u3068\u3057\u3066\u4f7f\u308f\u308c\u308b\u7b97\u8853\u5e73\u5747\u306b\u52a0\u3048\u3001\u25cb\u25cb\u7387\u306e\u5e73\u5747\u306a&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":1218,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"ja","_original_post":"https:\/\/obenkyolab.com\/?p=310","footnotes":""},"categories":[7],"tags":[],"class_list":["post-310","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","ja"],"_links":{"self":[{"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/posts\/310","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=310"}],"version-history":[{"count":27,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/posts\/310\/revisions"}],"predecessor-version":[{"id":585,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/posts\/310\/revisions\/585"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/media\/1218"}],"wp:attachment":[{"href":"https:\/\/obenkyolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}