<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>hayataka2049</author_name>
  <author_url>https://blog.hatena.ne.jp/hayataka2049/</author_url>
  <blog_title>静かなる名辞</blog_title>
  <blog_url>https://hayataka2049.hatenablog.jp/</blog_url>
  <categories>
    <anon>python</anon>
    <anon>scipy</anon>
  </categories>
  <description>情報理論でとてもよく出てくる情報エントロピー。計算するにはどうすれば良いのだろう？ 選択肢1：定義どおり作る 定義はとても簡単です。注意するべきことは、入力に0が来たときのパターンを想定しないで作るとmath domain errorが出る（は定義できないからね・・・）。 from math import log2 def H(lst): return -sum([x*log2(x) if x != 0 else 0 for x in lst]) print(H([0.5, 0.5])) # 1.0 選択肢2：scipyを使う scipyにそのものずばりのentropyという関数がある。sci…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fhayataka2049.hatenablog.jp%2Fentry%2F2018%2F01%2F22%2F151849&quot; title=&quot;【python】pythonで情報エントロピーの計算 - 静かなる名辞&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url>http://chart.apis.google.com/chart?cht=tx&amp;chl=%5Clog_20</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2018-01-22 15:18:49</published>
  <title>【python】pythonで情報エントロピーの計算</title>
  <type>rich</type>
  <url>https://hayataka2049.hatenablog.jp/entry/2018/01/22/151849</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
