エンタープライズ向け アプリケーション開発の例 - …...oprice = exp(-r * t) *...
TRANSCRIPT
![Page 1: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/1.jpg)
1© 2014 The MathWorks, Inc.
エンタープライズ向けアプリケーション開発の例
MathWorks® Japan
アプリケーションエンジニアリング部アプリケーションエンジニア吉田剛士
![Page 2: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/2.jpg)
2
アジェンダ
低コスト・低リスクなプロトタイプ開発
デモンストレーション– Amazon Redshift上のCANデータの集約
拡張性とアプリケーション展開
まとめ
![Page 3: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/3.jpg)
3
Excel VBA の場合
MATLAB の場合
MATLABの特徴Excel VBA vs. MATLAB
'Create the random numbersFor i = 0 To (nSteps - 1)
For j = 0 To (nSims - 1)mat(i, j) = gauss()
'scale the numbers and add onemat(i, j) = Exp((r - divYield - sig ^ 2 / 2) * dT + sig * Sqr(dT) * mat(i, j))
Next jNext i
'Once we have the scaled numbers, we need to do the cumulative product to simulate asset pathsFor i = 1 To (nSteps - 1)
For j = 1 To (nSims - 1)mat(i, j) = mat(i, j) * mat(i - 1, j)
Next jNext i
' Now, we want to get the average asset valueDim avPrices() As DoubleReDim avPrices(nSims - 1)
For j = 0 To (nSims - 1)For i = 0 To (nSteps - 1)
avPrices(j) = avPrices(j) + mat(i, j)Next i
'Take the average priceavPrices(j) = avPrices(j) * S / nSteps
'Take off the strike/exerciseavPrices(j) = avPrices(j) - E
'If zero, floor on zeroIf avPrices(j) < 0 Then
avPrices(j) = 0End If
Next j
'Now, take the average payoff and discountDim oprice As Doubleoprice = 0For i = 0 To (nSims - 1)
oprice = oprice + avPrices(i)Next ioprice = Exp(-r * T) * oprice / nSims
'Return the option priceApplication.Range("E12").Value = oprice
End Subコードは70行
![Page 4: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/4.jpg)
4
マクロ(VBA)の場合
MATLABの場合
MATLABの特徴Excel VBA vs. MATLAB
function [C, Sij] = opasian(S0,K,r,T,sigma,q,nSims,nSteps)
Dt = T/nSteps; % Determine the timestep
Eij = exp( (r -q -sigma^2/2)*Dt + sigma*sqrt(Dt).*randn(nSteps , nSims) );
Sij = S0 .* cumprod(Sij,1);
Ci = exp(-r*T) * max(mean(Sij)-K, 0); % Convert to NPV
C = mean(Ci) % Convert to NPV
– プログラミング言語として
コード量が少ない
デバッグ作業が効率的
実行時間は一般に5%以下
![Page 5: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/5.jpg)
5
パッケージ製品では届かないサービスを提供
ユーザ講演(2014/08/27 弊社開催セミナーにて)デロイト トーマツ コンサルティング様
![Page 6: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/6.jpg)
6
クラウドサービスの利用
MATLABライセンスは「Bring Your Own License」
On-Premise vs. Cloud
– On-premise は「自前の」と訳すと意味が通じます
– Cloud であれば最新のHW環境で
パワフルな計算を実現
– AWS Marketplaceを利用すると
インストールの手間なし
– 詳細は展示ブースへ
![Page 7: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/7.jpg)
7
アジェンダ
低コスト・低リスクなプロトタイプ開発
デモンストレーション– Amazon Redshift上のCANデータの集約
拡張性とアプリケーション展開
まとめ
![Page 8: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/8.jpg)
8
Demonstration OverviewAmazon Redshift上のデータ集約
GPS情報および車両走行情報(CAN)の集約– 総走行距離(3D)
– 最高高度とその際の住所
– 最高速度とその際の住所
といった計算を実施
![Page 9: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/9.jpg)
9
応用事例
Fleet / Probe解析
Prognostics解析
列車の走行解析・線路保守
構造物センサー
防犯カメラの解析
タクシーの配車 / 宅配便
介護 / 迷子
etc.
![Page 10: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/10.jpg)
10
開発/実行場所
データ解析モデリング
アルゴリズム開発
アプリケーション開発
アルゴリズムの探求
データ解析ワークフロー
ファイル
ソフトウェア
ハードウェア
C/C++/Javaなど
データへのアクセス
ドキュメント生成
組み込み開発
アプリケーションとして配布
結果の共有
![Page 11: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/11.jpg)
11
Access
Import
Amazon EC2
– クラウド上の仮想サーバー。AWS Marktplaceを通じてインストール
作業なしでMATLABを動作させることができる
Amazon Redshift
– PostgreSQL 8.0.2 に基いたペタバイト規模データウェアハウス
課題 : Redshiftへのアクセス大規模データのインポート
![Page 12: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/12.jpg)
12
Discover & Explore
補正前 補正後
課題 : 地図サービスとの連携異常値除去と補間
![Page 13: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/13.jpg)
13
Share
Webサーバを介した解析結果の共有– 表やグラフの社内展開
– 解析結果のWeb配信
Web
Browser
End User
課題 : HTML形式のレポート生成
![Page 14: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/14.jpg)
14
Amazon RedshiftAccess
>> setdbprefs(‘DataReturnFormat’, ‘table’); % Table型でインポート
>> % Redshiftへ接続
>> conn = database(‘<DBName>', ‘<UserName>', ‘<Password>', 'org.postgresql.Driver', 'jdbc:postgresql://<JDBC_URL>');
>> dbds = datastore(conn, ‘select * from cannovi order by devicetime’); % Select文の発行
>> whos dbds
Name Size Bytes Class Attributes
dbds 1x1 112 matlab.io.datastore.DatabaseDatastore
Database Toolbox™
![Page 15: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/15.jpg)
15
Datastore大規模テキストファイル/ビッグデータ向けオブジェクト
テキストファイル or データベースからの読み込み– テキストファイル(アスキーファイル)
Normal File System
Hadoop Distributed File System (HDFS)
MapReduce
– ODBC / JDBC準拠のデータベース
特徴
>> whos dbds
Name Size Bytes Class Attributes
dbds 1x1 112 matlab.io.datastore.DatabaseDatastore
Datastoreを作成してもデータは未取得
![Page 16: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/16.jpg)
16
Datastore大規模テキストファイル/ビッグデータ向けオブジェクト
データへのアクセス– read
3行ずつの読み込み
50行ずつ読み込んで処理を行う
resetでカーソルの巻き戻し
– readall
全データの読み込み
>> read(dbds, 3) % 第2引数で行数を指定
>> while hasdata(dbds)
read(dbds, 50)
:
end
>> Data = readall(dbds);
>> reset(dbds);
Timestamp Longitude Latitude …
09:17:32.427 -83.4756 42.4834 …
09:17:33.432 -83.4756 42.4834 …
09:17:34.432 -83.4756 42.4834 …
09:17:35.436 -83.4756 42.4834
09:17:36.420 -83.4756 42.4834 …
09:17:37.425 -83.4756 42.4834 …
09:17:38.450 -83.4756 42.4834 …
09:17:39.422 -83.4756 42.4834 …
: : : :
09:55:41.416 -83.4374 42.4430 …
09:55:42.418 -83.4374 42.4430 …
09:55:43.419 -83.4374 42.4430 …
cursor
![Page 17: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/17.jpg)
17
TableR2013bの新機能
特徴– 変数名付データ
利点– 変数名を使ってアクセス可能
– データが比較的コンパクト
Name Size Bytes Class Attributes
Data 1495x18 3336530 cell
>> Data.latitude
ans =
42.4834
42.4834
42.4834
:
>> Data
ans =
gpstime devicetime ...
_______________________ _________________________ _______
'2014-04-11 09:17:30.0' '2014-04-11 09:17:32.427' ...
'2014-04-11 09:17:30.0' '2014-04-11 09:17:33.432' ...
'2014-04-11 09:17:30.0' '2014-04-11 09:17:34.432' ...
Name Size Bytes Class Attributes
Data 1495x18 663370 table
![Page 18: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/18.jpg)
18
様々な地図サービス/データとの連携Discover & Explore
地図解析および可視化– ベクタ/ラスタデータのインポート・エクスポート
– 2D/3D地図表示
– WMS (Web Map Service) へのアクセス
– デジタル地形や標高の分析
– 地図フォーマットの変換
– Webブラウザ上でのインタラクティブな地図表示
Mapping Toolbox™
![Page 19: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/19.jpg)
19
データの前処理Discover & Explore
論理配列を使った異常値の除去
N次元配列までサポートする補間関数– interp1 / interp2 / interp3 / interpn
最近傍補間
線型補間
3次スプライン補間
3次畳み込み補間
区分的3次エルミート内挿多項式(interp1のみ)
>> Longitude(Data.horizontaldilution >= 30) = NaN; >> Latitude(Data.horizontaldilution >= 30) = NaN;
![Page 20: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/20.jpg)
20
様々な解析方法が試せる!Discover & Explore
専門・非専門分野の手法を手軽に適用できる環境
Signal Processing Toolbox™
Control System Toolbox™
System Identification Toolbox™
Wavelet Toolbox™
Econometrics Toolbox™
Optimization Toolbox™
Global Optimization Toolbox
Statistics Toolbox™
![Page 21: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/21.jpg)
21
HTMLレポートの作成Share
グラフや表を埋め込んだレポート生成
章や節などの構成設定
HTMLの他に、RTF/XML/PDF/
Microsoft Word®をサポート
MATLAB Report Generator™
![Page 22: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/22.jpg)
22
デモ : Amazon Redshift上のデータ集約- Challenges
Access
– Amazon Redshift へのアクセス
– 大規模データインポート
Discover & Explore
– 地図サービスとの連携
– 異常値除去と補間
Share
– Webサーバを介した情報共有の
ためのHTML生成
AWSサービスの利用
Data Analytics
![Page 23: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/23.jpg)
23
デモ : Amazon Redshift上のデータ集約- MATLAB Solutions
Access
– ODBC/JDBCドライバをサポート
– datastoreの利用
– Vehicle Network Toolbox™によるCANインポート
Discover & Explore
– 地図情報専用製品を提供
– 高速で柔軟なデータの前処理
Share
– HTMLを含めた様々な
ファイル形式でのレポート生成
![Page 24: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/24.jpg)
24
アジェンダ
低コスト・低リスクなプロトタイプ開発
デモンストレーション– Amazon Redshift上のCANデータの集約
拡張性とアプリケーション展開
まとめ
![Page 25: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/25.jpg)
25
Scalability計算リソースの有効活用
Scale-up
– Parallel Computing Toolbox™
Scale-out
– MATLAB Distributed Computing Server™
MATLAB
Desktop (Client)
Local
Desktop Computer
Computer Cluster
Scheduler
![Page 26: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/26.jpg)
26
MapReduce
Parallel Computing Toolbox
Parallel Computing Toolbox
MATLABDistributedComputingServer
![Page 27: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/27.jpg)
27
Application Deployment非ユーザに対する実行環境の提供
Computer Cluster
MATLAB Production Server™
Shared
Directory
Web
Browser
End User
without License
MATLAB
Toolboxes
Java
www
MATLAB Compiler™
![Page 28: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/28.jpg)
28
Application Deployment非ユーザに対する実行環境の提供
MATLAB
Toolboxes
Computer Cluster
MATLAB Production Server
Shared
Directory
Excel
End User
without License
MATLAB Compiler™
MATLAB Builder™ EX
![Page 29: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/29.jpg)
29
地図アプリケーション開発
株式会社ゴーガ様のソリューション
![Page 30: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/30.jpg)
30
アジェンダ
低コスト・低リスクなプロトタイプ開発
デモンストレーション– Amazon Redshift上のCANデータの集約
拡張性とアプリケーション展開
まとめ
![Page 31: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/31.jpg)
31
まとめエンタープライズ向けアプリケーション開発の例
開発としてのMATLAB
– コード量が少なくデバッグが容易
– APIが柔軟
– 豊富なライブラリ群
実行環境としてのMATLAB
– 高いスケーラビリティ
– サーバ運用を想定したアプリケーション展開
Webサービス
Microsoft Excel®計算エンジン
ロイヤリティフリーで運用可能
![Page 32: エンタープライズ向け アプリケーション開発の例 - …...oprice = Exp(-r * T) * oprice / nSims 'Return the option price Application.Range("E12").Value = oprice End](https://reader034.vdocuments.net/reader034/viewer/2022042302/5ecdd44c3170013f4a478fa8/html5/thumbnails/32.jpg)
32
MATLAB によるデータサイエンス~統計解析・機械学習と大規模データ~
開催地 : 東京、御茶ノ水会場 : TKP ガーデンシティ御茶ノ水日付 : 2014 / 12 / 5 (金曜日)時間 : 13:30 ~ 17:00
MATLABによるデータ解析入門 (13:30 ~ 14:20)
MATLABによる統計解析・機械学習 (14:30 ~ 16:40)
大規模データへの処方箋 (16:40 ~ 17:00)