LoginSignup
0

More than 5 years have passed since last update.

PyMieScatt > MiePiTau() > Equation of Pi() and Tau() > Off-by-one errorを起こしそうな実装

Posted at
動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 16.04.4 LTS desktop amd64
TensorFlow v1.7.0
cuDNN v5.1 for Linux
CUDA v8.0
Python 3.5.2
IPython 6.0.0 -- An enhanced Interactive Python.
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
scipy v0.19.1
geopandas v0.3.0
MATLAB R2017b (Home Edition)
ADDA v.1.3b6
gnustep-gui-runtime v0.24.0-3.1

Reference

Equation of Pi() and Tau()

  for n in range(2,int(nmax)):
    p[n] = ((2*n+1)*(mu*p[n-1])-(n+1)*p[n-2])/n
    t[n] = (n+1)*mu*p[n]-(n+2)*p[n-1]

対応する式はonline user's guideに記載されている。

しかしながら、online user's guideに記載の式と上記の実装ではnの扱いが異なる。

実装の式は以下のようになっている。

\pi_n = \frac{(2n+1)\mu \pi_{n-1} - (n+1)\pi_{n-2}}{n}

user's guideの式は以下のようになっている。

\pi_n = \frac{2n-1}{n-1}\mu \pi_{n-1} - \frac{n}{n-1}\pi_{n-2}

user's guideの式のnをn+1にすると実装と同じになる。

インデックスの取り方により、こういうことをしないといけないのだろうか。

Off-by-one errorを起こしそうな実装である。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0