![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
CQエレクトロニクス・セミナ「実習・マイコンを動かしながら学ぶディジタル・フィルタ」で使う適応線スペクトル強調器(ALE)のプログラム.ステップサイズパラメータをターミナルから変更できる. http://seminar.cqpub.co.jp/ccm/ES18-0020
Dependencies: F746_GUI F746_SAI_IO mbed
Filter/GaussRand.hpp@4:bde47691ec93, 2018-09-04 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Tue Sep 04 05:52:44 2018 +0000
- Revision:
- 4:bde47691ec93
- Parent:
- 0:c8e52f514e03
5
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:c8e52f514e03 | 1 | //--------------------------------------------------------- |
MikamiUitOpen | 0:c8e52f514e03 | 2 | // 線形合同法による一様乱数を使い,中心極限定理を利用する正規乱数発生 |
MikamiUitOpen | 0:c8e52f514e03 | 3 | // <文献> |
MikamiUitOpen | 0:c8e52f514e03 | 4 | // 三上直樹:「アルゴリズム教科書」,第11章,CQ出版,1996年. |
MikamiUitOpen | 0:c8e52f514e03 | 5 | // |
MikamiUitOpen | 0:c8e52f514e03 | 6 | // 2018/03/02, Copyright (c) 2018 MIKAMI, Naoki |
MikamiUitOpen | 0:c8e52f514e03 | 7 | //--------------------------------------------------------- |
MikamiUitOpen | 0:c8e52f514e03 | 8 | |
MikamiUitOpen | 0:c8e52f514e03 | 9 | #include "Random.hpp" |
MikamiUitOpen | 0:c8e52f514e03 | 10 | |
MikamiUitOpen | 0:c8e52f514e03 | 11 | namespace Mikami |
MikamiUitOpen | 0:c8e52f514e03 | 12 | { |
MikamiUitOpen | 0:c8e52f514e03 | 13 | class GaussRand |
MikamiUitOpen | 0:c8e52f514e03 | 14 | { |
MikamiUitOpen | 0:c8e52f514e03 | 15 | public: |
MikamiUitOpen | 0:c8e52f514e03 | 16 | // sigma 標準偏差 |
MikamiUitOpen | 0:c8e52f514e03 | 17 | // av 平均値 |
MikamiUitOpen | 0:c8e52f514e03 | 18 | GaussRand(float sigma, float av) |
MikamiUitOpen | 0:c8e52f514e03 | 19 | : sigma_(sigma), av_(av), rd_(901253) {} |
MikamiUitOpen | 0:c8e52f514e03 | 20 | GaussRand(float sigma, float av, uint32_t x) |
MikamiUitOpen | 0:c8e52f514e03 | 21 | : sigma_(sigma), av_(av), rd_(x) {} |
MikamiUitOpen | 0:c8e52f514e03 | 22 | |
MikamiUitOpen | 0:c8e52f514e03 | 23 | // 中心極限定理を利用する正規乱数発生 |
MikamiUitOpen | 0:c8e52f514e03 | 24 | float Next() |
MikamiUitOpen | 0:c8e52f514e03 | 25 | { |
MikamiUitOpen | 0:c8e52f514e03 | 26 | float gauss = 0; |
MikamiUitOpen | 0:c8e52f514e03 | 27 | for (int n=0; n<12; n++) gauss += rd_.Next(); |
MikamiUitOpen | 0:c8e52f514e03 | 28 | return sigma_*(gauss - 6.0f) + av_; |
MikamiUitOpen | 0:c8e52f514e03 | 29 | } |
MikamiUitOpen | 0:c8e52f514e03 | 30 | |
MikamiUitOpen | 0:c8e52f514e03 | 31 | private: |
MikamiUitOpen | 0:c8e52f514e03 | 32 | float sigma_; |
MikamiUitOpen | 0:c8e52f514e03 | 33 | float av_; |
MikamiUitOpen | 0:c8e52f514e03 | 34 | Mikami::Random rd_; |
MikamiUitOpen | 0:c8e52f514e03 | 35 | }; |
MikamiUitOpen | 0:c8e52f514e03 | 36 | } |