ラベル

AI Forecast 8306MUFG (213) Social (75) life (70) Financial (62) IT (57) Proposal (56) idea (50) Fund Management (48) Trading (43) economics (42) Covid-19 (40) AI (38) Hedge Fund (36) Risk (36) Culture (31) BOJ (29) Science (26) hobby (24) accounting (17) Apps (16) career (11) job (7) Travel (6) Hiking (5) emotion (5) music (3) Statarb (2) piano (2)

2019年11月28日木曜日

AIで温度管理の実験をしよう AI Temperature Control Play Ground

AIで温度管理してみよう

AI Temperature Control Play Ground


エアコンの温度管理をAIでやってみよう。熱伝導方程式による解析的なアプローチよりはるかに簡単に、ニューラルネットは「動物的カン」で答えをだすのである。Let's control air conditioner by AI. Far easier than analytical solution by solving heat conduction equation, neutral network gives out answer like animal hunch.

温度を一定に保つ初期の装置はバイメタルによるOn/Offだった。でも、今は、ニューラルネットがよりスマートにやってくれる。Early day's temperature stabilization was done by bi-metal to perform on/off. But now neutral network does it more smoothly.

下のプログラムでは、外気温、エアコンダイアル設定(+は暖房/-は冷房)、室内温度について9つのデータを取った結果でニューラルネットを教育している。In the program below, AI takes 9 data sample for outside temperature, air conditioner setting(+for heating/-for cooling), and inside temperature.

いろいろパラメータを変えて走らせてみよう。You can change parameter and play around in the test environment. Pls try.

活性化関数は全部で11ある。There are all 11 activation functions you can try (elu, hardsigmoid, linear, relu, relu6, selu, sigmoid, softmax, softplus, softsign, tanh).

プログラムはこちら。Codes are here. 



Air Conditioning AI Controller
Decide control level to achieve target room tempetature

#OfNeurons/layerニューロン数/層
#ofEpoc教育繰り返し回数
InputLyrActivFunc入力層活性化関数
HidnLyrActivFunc中間層活性化関数
#ofHiddenLayer中間層の数

データー番号 data number   
               
x. 外気温temperature   outside
               
z. 冷暖力Air conditioning power (+warm/-cool)
               
y. 最終室温Final room temperature
               


2019年11月20日水曜日

超簡単ブルースアドリブ(Super Easy Blues improvisation)

超簡単ブルースアドリブ

Super Easy Blues improvisation




ダイアトニックスケール(1/1/0.5/1/1/1/0.5)でキーがCの時、コード進行の上に、ブルーススケール(2.5/1/0.5/0.5/2.5/0.5)構成音(C/Eb/F/Gb/G/Bb)をランダムにリズムに乗せるだけでブルースアドリブが完成。途中にクロマチックスケール(0.5/0.5/0.5/0.5/...)など他のスケールも入れるともっとカッコ良くなる。やってみよう!びっくりするほど役に立つよ!

キーボード:Roland FP-5
コード進行:セッションパートナーr.1ポップス
音色:161アルトサックス When you are in key C diatonic scale(1/1/0.5/1/1/1/0.5) chord progression, you can just randomly put C blues scale (2.5/1/0.5/0.5/2.5/0.5) notes C/Eb/F/Gb/G/Bb to have quick and easy improvisation. Inserting other scale such as chromatic scale (0.5/0.5/0.5/0.5/...) will make it sounds nicer. Try it and you will find it totally surprisingly useful.

Keyboard:Roland FP-5
Chord progression: Session Partner r.1 Pops
Instrument : 161 Alt Sax

円コイン(中央銀行デジタル通貨)の構造 The Architecture of Yen Coin(CBDC)

円コイン(中央銀行デジタル通貨)の構造 The Architecture of Yen Coin(CBDC)



LIBRAからの挑戦もあって、中央銀行によるデジタル通貨(CBDC)の議論が始まった。日銀のスライド(2019/7/5 [参考1])には、プリペイドカード形式での導入案が紹介されている。LIBRAの最大の利点は国境を透過するPTP(個人間)決済である。PTP決済ができて初めてCDBCは「お札」と同等の利便性をもつ。LIBRAは各国通貨にリンクするステーブルコインであるが、マネロン対策、通貨主権の観点からグローバルな公式展開は許容されなかった。Facing challenges from LIBRA, discussion on CBDC(Central Bank Digital Currency) has started. BOJ made prepaid card style proposal as in Reference 1. Meanwhile LIBRA's biggest advantage is PTP settlement across boundaries. CBDC becomes cash equivalent only when PTP settlement is possible. LIBRA was rejected by countries due to lack of money laundering measure as well as risk of invasion on sovereignty, although it is a stable coin linked to currency of each countries.

ここではPTP(個人間)決済の利便性・マネロン対策・国家の通貨主権・金融政策のすべてを満足するCBDCの形態を段階別に2つ提案したい。Here, I wish to propose two-stage approach for development of CBDC that satisfies all problems that LIBRA has.

第一段階 日銀券(お札・硬貨)だけを円コイン化 
Stage 1. Convert Central Bank Note to CBDC 
  • 日銀の口座型CBDCのプラン[参考1]をPTP(個人間)化する。発行済み日銀券(現在100兆円)を保有しているすべての経済主体(個人・法人・含非居住者)は日銀のバランスシート上にアカウントを持ち、互いにCBDCを日銀口座間振替で決済できる体制に移行する。Convert BOJ's proposal in Reference-1 to PTP. All economic body own account on BOJ balance sheet and can settle CBDC mutually. 
  • 円の全利用者のトランザクションをリアルタイムで行うインフラの整備が必須なため、追加投資を最小にするため、当面、銀行に当座預金、普通預金の他に政府預金を追加してもらい、口座振替は政府預金間のみ許可する対応も一案。To save cost of implementation, it may be an idea to mandate existing commercial banks to include government account access in their existing services while approving settlement only in between government accounts by way of CBDC. 
  • PTP決済が可能で現在の現金と利便性は同等以上、アカウントは国民識別IDなどと対応させることでマネロン対策になり、その他現状の、国家の通貨主権、金融政策などはそのまま維持される。This makes CBDC as convenient as current cash while having anti money laundering feature through national ID linkage. Currency sovereignty as well as monetary policy will be maintained. 
第二段階 すべての円のコイン化
Stage 2. Convert all Yen to CBDC 


  • 特徴 Feature
    1. 送金・振替は日銀口座間のみ合法とする。銀行口座間振替は順次停止する。Make only settlements in between CBDC as legal. Money transfers between existing bank accounts will be stopped. 
    2. 日銀の口座に存在する円のみを有効な円と告知する。具体的な会計仕訳は[参考2]を参照。Declare that only Yen in BOJ accounts is valid Yen. Accounting sample entries are shown in Reference-2. 
    3. 円の利用者は日銀の自分の口座で資金を保存する選択ができ、銀行の信用リスク(取付騒ぎ)を回避する選択肢を持つ。Yen users now have right to keep fund at BOJ account, thus can avoid bank's credit risk(bank run). 
    4. マネロン対策、国家の通貨主権、金融政策は引き続き維持される。 Anti money laundering, Currency sovereignty as well as monetary policy will be maintained. 
  • 管理Management
    1. すべての円はコイン化され、円コインの決済はすべて、日銀のバランスシート上で行われるため、準備率という概念は消滅し、通貨供給量は日銀のバランスシートの大きさとなる。There is no central bank reserve concept anymore while money supply is directly monitored by the size of BOJ balance sheet. 
    2. すべての円の動きがリアルタイムに日銀バランスシート上で管理できる。All Yen movement is monitored on BOJ balance sheet on real time. 
  • 法制Legal framework
    1. 円コインの決済にかかわらない会計処理は基本現状通りとなる。Accounting process irrelevant to Yen coin settlement will be kept as current manner.
    2. 現状の金融契約はそのまま大きな変更なく継続利用できる。Existing financial contracts will be kept as they are without any major changes. 
[参考1] Reference 1

2019年11月17日日曜日

強化学習も関数補間 Reinforcement Learning is also Function Interpolation

強化学習も関数補間

 Reinforcement Learning is also Function Interpolation




AIの「教師あり学習」と「強化学習」とは異なる方法と感じる人も多いだろう。強化学習の代表選手であるQ学習は、関数の補間機能である「教師あり学習」と比べ、どこが違うのだろうか。Many may feel that supervised learning and reinforcement learning are different. What is the difference between Q learning representing reinforcement learning and supervised learning that interpolate functions?

実は、Q学習も「教師あり学習」も、全空間を記述する関数、即ち補間関数を作り上げようとしている点で、本質的な違いはない。In reality, there is no fundamental difference between the Q learning and supervised learning since both try to establish interpolating function describing whole problem universe.

Q学習においては、環境に対し、エージェントが行動Aをとり、報酬rを得た場合、状態Sと行動Aの組合せにおける価値Qを、Qテーブルという表に保存する。テーブルというデータ構造上、全空間は離散化されているが、DQN(Deep Q Neural Network)を使えば離散化は不要となる。なお、Q関数は一般的にはN次元だが、上の図は見易くするため、2次元で書いてある。In Q learning, value Q at state S and action A is stored in table called Q table when agent took action A against environment. Whole problem universe is discritized due to table in nature while such discritization will be unnecessary if DQN(Deep Q neural Network) is used. Q is N dimensional in general however for ease of presentation, it is shown as 2 dimensional.

次のサイクルの行動Aは、現在の状態Sの場合のQを最大にするAとする。探索の幅を広げるために、Aの選択は時々ランダムを入れる。次の行動Aを環境に入れ、次のサイクルが始まる。The action A for next cycle is set by picking the A that makes Q maximum when state is S. For diversity expansion, take A randomly once in a while. The next cycle will start by applying action A to environment.

\begin{align} Q(S_{t},A_{t})  &\gets Q(S_{t},A_{t}) + \alpha(r_{t} + \gamma Max_{A}[Q(S_{t+1},A)] - Q(S_{t},A_{t}) )  \\
&\gets (1-\alpha)Q(S_{t},A_{t}) +\alpha(r_{t} + \gamma Max_{A}[Q(S_{t+1},A)] ) \\  \\

S_{t}  &:  時刻tにおける状態 \ State \ at \ time \ t \\
A_{t} &:  時刻tにおける行動 \ Action \ taken \ at \ time \ t \\
Q(S_{t},A_{t})   &:  S_{t}、A_{t}の場合の価値 \ Value \ at \  S_{t},  \ A_{t} \\
\alpha &:  学習率 \ learning \ rate\\
r_{t}   &:  報酬 \ reward\\
\gamma   &: 割引率 \ discount \ factor\\
Max_{A}[Q(S_{t+1},A)] )   &: A変化時のQの最大値 \ Max \ Q \ by \ varying \ A  \\
\end{align}

「教師あり学習」では最初から大量の教育データがあったが、強化学習では、最初の状態からいろいろ試行を重ねるたびに教育データを集積していくところが異なる。しかし、解の全空間を対象にした補間関数を求めているという点では全く一致している。Supervised training has big data for education but reinforcement learning accumulates data as making try & error.  However, both are identical from the point of seeking for interpolation function covering whole problem universe in scope.

 このため、過去のデータなどから教育データを生成できる場合は、強化学習より「教師あり学習」が効率が良い。一方、二足歩行、ゲームなど、最初の状態が明確で、そこから分岐していくデータのみに意味がある場合など、範囲を絞り込むなんからの境界条件がある場合は強化学習が適している。Hence, if historical data is well prepared, it is more efficient to use supervised learning. Meanwhile, if initial condition is clear followed by consequential status where bounds are rather limited with boundary condition, reinforcement learning may fit.

 この学習の過程を考えていると、人間の学習とダブって見える。最初の教え方がまずいと、紆余曲折、遠回りをして目的を達成することになるが、その過程で、普通なら体験しない様々な場面に遭遇し人生を豊にする。This reinforcement learning process overlaps the process of learning done by human being. If initial instruction is not correctly provided, we end up going around, making detour to achieve objective however, during such elongated process, we may face many interesting situations that other will not encounter, then life will be more fascinating.

 人生の選択は組合せの爆発で、全てのケースを「教師あり学習」することは不可能だ。自然、強化学習となり、そこでは少ないサンプルの試行錯誤の経験値を元に最適化を図っていくことになる。しかし過学習の果て、状態が少しでもずれると利用できなくなったり、逆にデータの少なさにより学習が収束しなかったりなど、少ないサンプルでの収束には問題も多い。これは人間にも言えることで、修練を重ねることで強くなっていく。The choice in life is an explosion of combination, hence it is impossible to have supervised learning for the whole problem universe. Naturally learning will be reinforcement learning where optimization is based on try and error. However over learning destroy robustness while data scarcity makes non convergence.  This applies to human life also however it is mitigated by multiple training.

 この強化学習の考え方は生命の学習と近いものがある。環境が与えたある範囲の最適関数をいち早く正しく習得した個体が生き残る。This reinforcement learning idea is similar to learning by living creatures. Only those that learn the optimized function given by environment correctly and quickly should survive.

2019年11月15日金曜日

格安スマホ革命.. 中国製スマホはEbayをチェック Smart Phone Revolution .. Check Ebay for Chinese Smart Phone

格安スマホ革命.. 中国製スマホはEbayをチェック 
Smart Phone Revolution .. Check Ebay for Chinese Smart Phone



格安スマホの本流を行く1機種を紹介したい。Let me introduce one main streamer of cheap smart phone.

それはDoogee X5 Max Proだ。4,000mAhのバッテリーで中国製格安スマホにありがちな連続使用時間を解消し、信頼性ともに十分に実用的である。It is Doogee X5 Max Pro. Equipped with 4,000mAh battery, it solves battery shortage problem unlike other Chinese cheap smart phones. Reliable and performance is high enough. 

今日現在、本体価格1万円程度、交換バッテリーは千円程度だ。It costs only JPY10K and battery costs JPY1K as of today.

Amazonでは取り扱いが不定期だが、Ebay(US)では本体・バッテリー共、通年在庫がみつかる。Amazon does not have consistent inventory but Ebay(US) does  including battery throughout a year.

現在新たに楽天がキャリアとして参入するが、SIMベースの格安スマホでほぼ同様のサービスが数分の1の価格で実現できる現在、大手キャリアはその存在意義を問われている。Rakuten is now jumping into smart phone business as new career however, such careers are now questioned for their existence facing super cost effective cheap smart phones based on SIM.

また、統一ブランド名の下で、格安スマホ利用を端末購入から設定まで一貫して有償サポートするビジネスも成り立つ。宣伝をうまくやれば革命がおこるかもしれない。As a new business chance, paid service to support cheap smart phone implementation from purchase to setting up is possible. If done well for advertisement, can create revolution to the smart phone business.










2019年11月13日水曜日

プログラミングと数学(小さな発見) Programming and Mathematics(One Tiny Finding)

プログラミングと数学(小さな発見) Programming and Mathematics(One Tiny Finding)



CartPoleという棒立ての問題をQテーブルを用いて離散的に強化学習するPythonのステップを読んだ。4要素の連続値ベクタを5ステップに離散化したのち、スカラーに次元圧縮するロジックを見つけて感動した。I read Python code for reinforced learning using Q table for CartPole problem to let pole keep standing on the cart.  Very impressed to find out one logic to perform dimension reduction from 4 dimension to scalar on 4 element continuous number vector with 5 step discretization.

最初、下記の赤の部分が何をしているのか不明だった。いろいろ見ていくうちに、離散化ステップをNとしたN進法で次元圧縮しているのだということが分かり、「アッタマいい!」と納得した。プログラムは単なるコーディングでなく、いろいろな知恵の集合体であることを再認識した。Initially no idea what below red part is doing.  While reading further, I realized that it is a N base dimension reduction taking number of discritization steps as N. Very smart way to do all at once.  At the same time I realized again that programming is not just a coding but including lots of wisdom.

def digitize_state(observation):
    cart_pos, cart_v, pole_angle, pole_v = observation
    digitized = [
        np.digitize(cart_pos, bins=bins(-2.4, 2.4, num_dizitized)),
        np.digitize(cart_v, bins=bins(-3.0, 3.0, num_dizitized)),
        np.digitize(pole_angle, bins=bins(-0.5, 0.5, num_dizitized)),
        np.digitize(pole_v, bins=bins(-2.0, 2.0, num_dizitized))
    ]
    return sum([x * (num_dizitized**i) for i, x in enumerate(digitized)])

リアルフォン計画.シンプルなIP電話 Project Real Phone. Most Simple Phone

リアルフォン計画.シンプルなIP電話
English follows




すべては実際、IP接続が出来た時点で終わっていた。 音声、画像、データは、IP接続の下ではすべて同じデータだ。

しかし、今まで実際の運用は種類別に行われた。 音声電話は従来型の課金システムに縛られ、 IP電話が急激に広まることはなかった。

現在、IP電話は、LINE、Skype、WeChat、などに分かれ統一感はまったくない。

ここで提案がある。

シンプルな、PtP IP接続を実現しよう。複雑なシステムはいらない。

その名前は「フォン」一言。 だれでも番号を持ち、お互いにIP電話で通話できる。 中央にリポジトリを持ち、PtPのIP接続のみをサポートする。

フォンにアカウントを持つには、パスポート、運転免許証などの認証を求める。またフォンは音声、映像、データ、など、すべてのサービスをPtPで実現する。これにより、アカウントを持つだけで、ユーザーはビデオ電話、会議、データ交換などが自由に行えるようになるのだ。

Project Real PHONE. Simple IP Phone



In reality, all setup has been done long time ago when IP connection has been established. Under IP connection, voice, video, data are all under same category, that is data.

However, up until now, the actual operation has been done by type of data. Voice connection was bound by existing charging system, hence IP phone did not expand rapidly.

At this point, IP phones are split into LINE, Skype, WeChat and there is no consistency.

Here is one proposal.

Let's establish simple IP connection environment. No need for complex system.

The name is PHONE, one word. All has own code and call each other by IP phone. Central repository supports PtP IP connection only.

PHONE requires the due diligence process by passport/driver's license submission. The PHONE realize voice, video, data service on PtP basis. Just by having account, users can enjoy video, conference, data exchange freely.




中学校の合唱 Junior High Chorus

中学校の合唱

Junior High Chorus



中学校の合唱で子供がピアノ伴奏の役をもらった。クラスメートをまとめて一つの合唱を仕上げていく過程は子供から聞いていても感動的だ。クラスは最初ばらばらで、非協力的な人(特に男子)も多くいる。中学校のコーラスは小学校よりパート分割などより本格的になり、上手に歌えるとかなり聞きごたえがある。最初まったく参加していなかった生徒が最後は大きな力となって最後の発表会で歌っているのを聴くと、チームをまとめてプロジェクトを完遂させることを学ぶ非常に良い教育機会だと思う。

My kid was assigned to piano accompaniment for junior high chorus. The process of development of class chorus is impressive as I hear from Kids. Initially team is disoriented and members are not really cooperative(especially boys). Junior high chorus has multiple layers of chorus part splits, and sounds much better than elementary school chorus if done well. Seeing the eventual serious involvement to the team by all including those who initially not were not cooperative but now creating really good sounds, I felt this is a very good educational opportunity to learn how to complete project combining team to achieve goal.