<a href="https://colab.research.google.com/github/kojiyam/information-theory/blob/main/it5.ipynb" target="_parent"></a>

## $p=0$の場合のエントロピーの計算

$ \displaystyle \lim_{x\to+0} x \log x $


```
import numpy as np
```

以下のように，NumPyでは計算できない


```
np.log2(0)
```

    /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:1: RuntimeWarning: divide by zero encountered in log2
      """Entry point for launching an IPython kernel.





    -inf




```
0*np.log2(0)
```

    /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:1: RuntimeWarning: divide by zero encountered in log2
      """Entry point for launching an IPython kernel.
    /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:1: RuntimeWarning: invalid value encountered in double_scalars
      """Entry point for launching an IPython kernel.





    nan




```
import sympy
from sympy.abc import x
# sympy.init_printing()
```


```
0*sympy.log(0)
```




    nan



極限であればOK


```
f = sympy.limit(x*sympy.log(x),x,0)
```


```
print(f)
```

    0


f431dd2e7fcfbcb312ed89fa53f3713f14d7d292
ipynb
Jupyter Notebook
it5.ipynb
kojiyam/information-theory
601cf119b8c7b5d24bd61594e2a4d7b9a8c6f223
MIT
it5.ipynb
kojiyam/information-theory
601cf119b8c7b5d24bd61594e2a4d7b9a8c6f223
MIT
it5.ipynb
kojiyam/information-theory
601cf119b8c7b5d24bd61594e2a4d7b9a8c6f223
MIT
Qwen/Qwen-72B
1. YES
2. YES