SlideShare uma empresa Scribd logo
1 de 7
Baixar para ler offline
配列数式
まるやま
2013/05/10
1 / 7
こんなデータがあったとする
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
0 0.5 1 1.5 2 2.5 3
result
causality
2 / 7
こんなデータがあったとする
横軸が原因、縦軸が結果
Excel 的に言うと、A1∼A400 セルに原因の値
B1∼B400 セルに、対応する結果の値が入っているとする
結果が正の値のデータは、原因と結果に相関がありそう!
結果が負の値のデータは、まぁいいとして
相関が有るのか無いのか調べるのは、相関係数!
3 / 7
Excelで相関係数の計算
Excel で相関係数の計算をするのは、簡単
例えば C1 セルに以下を入力する
=POWER(CORREL(A1:A400,B1:B400),2)
このデータで実際に計算してみたら、0.41
微妙な値…
それもそのはず
あまり相関の無さそうな、結果が負のデータも一緒に計算し
ているから
恣意的かもしれないけど、結果が正のデータだけで、相関係
数を計算したい
結果が負のデータを消す?
結果が正のデータを抜き出してコピー?
めんどくさい…
配列数式を使おう!
4 / 7
配列数式
C2 セルに以下を入力する
=POWER(CORREL(IF(B1:B400>0,A1:A400),
IF(B1:B400>0,B1:B400)),2)
入力した後に、Ctrl+Shift+Return を押す!
すると上の式全体が {} で括られる
手で {} を書いても、ダメ
これ(IF の部分)が配列数式!
この IF は、else 部分を省略した形
厳密に書くと、IF(B1:B400>0,A1:A400,0) となる
A1:A400 というセルの配列の中から、対応する B 列の値が正
の値のみを抜き出して、配列の形で出力する、という意味
入力した後に修正しようとして C2 セルをダブルクリックす
ると、配列数式が解除されてしまう
修正した後に、もう一度 Ctrl+Shift+Return する
このデータで実際に計算してみると、0.82
見事に相関がありそうな値になった!
5 / 7
複数の条件を組み合わせた配列数式
結果の値が正、かつ、結果の値が2未満のもの
IF((B1:B400>0)*(B1:B400<2),A1:A400)
結果の値が1未満、もしくは、結果の値が1より大きいもの
IF((B1:B400<-1)+(B1:B400>1),A1:A400)
IF の条件式は、あくまで数式の形であること
配列数式の場合は、AND, OR は使えない
もちろん普通の IF 文は AND, OR が使えるけど
AND の代わりに*, OR の代わりに+を使う
6 / 7
配列数式のExcel VBAマクロ
先ほどの配列数式を Excel VBA マクロで書くと、以下になる
Range(“C2”).FormulaArray = “=POWER(CORREL(IF(”
& Range(“B1:B400”) & “>0,” & Range(“A1:A400”)
& “),IF(”
& Range(“B1:B400”) & “>0,” & Range(“B1:B400”)
& “)),2)”
なんか VBA で書いたほうが簡単だなぁ
ちなみに、VBA マクロ以外、LibreOffice でも全く同じことが
出来ます
7 / 7

Mais conteúdo relacionado

Destaque

How to Develop Experiment-Oriented Programs
How to Develop Experiment-Oriented ProgramsHow to Develop Experiment-Oriented Programs
How to Develop Experiment-Oriented ProgramsKenta Oono
 
機械学習向けプログラミング言語の使い分け - RCO の場合
機械学習向けプログラミング言語の使い分け - RCO の場合機械学習向けプログラミング言語の使い分け - RCO の場合
機械学習向けプログラミング言語の使い分け - RCO の場合Maruyama Tetsutaro
 
Stochastic Gradient MCMC
Stochastic Gradient MCMCStochastic Gradient MCMC
Stochastic Gradient MCMCKenta Oono
 
高速・省メモリにlibsvm形式で ダンプする方法を研究してみた
高速・省メモリにlibsvm形式で ダンプする方法を研究してみた高速・省メモリにlibsvm形式で ダンプする方法を研究してみた
高速・省メモリにlibsvm形式で ダンプする方法を研究してみたKeisuke Hosaka
 
Introduction of “Fairness in Learning: Classic and Contextual Bandits”
Introduction of “Fairness in Learning: Classic and Contextual Bandits”Introduction of “Fairness in Learning: Classic and Contextual Bandits”
Introduction of “Fairness in Learning: Classic and Contextual Bandits”Kazuto Fukuchi
 
Differential privacy without sensitivity [NIPS2016読み会資料]
Differential privacy without sensitivity [NIPS2016読み会資料]Differential privacy without sensitivity [NIPS2016読み会資料]
Differential privacy without sensitivity [NIPS2016読み会資料]Kentaro Minami
 
Conditional Image Generation with PixelCNN Decoders
Conditional Image Generation with PixelCNN DecodersConditional Image Generation with PixelCNN Decoders
Conditional Image Generation with PixelCNN Decoderssuga93
 
Interaction Networks for Learning about Objects, Relations and Physics
Interaction Networks for Learning about Objects, Relations and PhysicsInteraction Networks for Learning about Objects, Relations and Physics
Interaction Networks for Learning about Objects, Relations and PhysicsKen Kuroki
 
Introduction of "TrailBlazer" algorithm
Introduction of "TrailBlazer" algorithmIntroduction of "TrailBlazer" algorithm
Introduction of "TrailBlazer" algorithmKatsuki Ohto
 
Fast and Probvably Seedings for k-Means
Fast and Probvably Seedings for k-MeansFast and Probvably Seedings for k-Means
Fast and Probvably Seedings for k-MeansKimikazu Kato
 
InfoGAN: Interpretable Representation Learning by Information Maximizing Gen...
InfoGAN: Interpretable Representation Learning by Information Maximizing Gen...InfoGAN: Interpretable Representation Learning by Information Maximizing Gen...
InfoGAN: Interpretable Representation Learning by Information Maximizing Gen...Shuhei Yoshida
 
Improving Variational Inference with Inverse Autoregressive Flow
Improving Variational Inference with Inverse Autoregressive FlowImproving Variational Inference with Inverse Autoregressive Flow
Improving Variational Inference with Inverse Autoregressive FlowTatsuya Shirakawa
 
Fractality of Massive Graphs: Scalable Analysis with Sketch-Based Box-Coverin...
Fractality of Massive Graphs: Scalable Analysis with Sketch-Based Box-Coverin...Fractality of Massive Graphs: Scalable Analysis with Sketch-Based Box-Coverin...
Fractality of Massive Graphs: Scalable Analysis with Sketch-Based Box-Coverin...Kenko Nakamura
 
Learning to learn by gradient descent by gradient descent
Learning to learn by gradient descent by gradient descentLearning to learn by gradient descent by gradient descent
Learning to learn by gradient descent by gradient descentHiroyuki Fukuda
 
Development and Experiment of Deep Learning with Caffe and maf
Development and Experiment of Deep Learning with Caffe and mafDevelopment and Experiment of Deep Learning with Caffe and maf
Development and Experiment of Deep Learning with Caffe and mafKenta Oono
 
Safe and Efficient Off-Policy Reinforcement Learning
Safe and Efficient Off-Policy Reinforcement LearningSafe and Efficient Off-Policy Reinforcement Learning
Safe and Efficient Off-Policy Reinforcement Learningmooopan
 
Dual Learning for Machine Translation (NIPS 2016)
Dual Learning for Machine Translation (NIPS 2016)Dual Learning for Machine Translation (NIPS 2016)
Dual Learning for Machine Translation (NIPS 2016)Toru Fujino
 
Matching networks for one shot learning
Matching networks for one shot learningMatching networks for one shot learning
Matching networks for one shot learningKazuki Fujikawa
 
5分でわかるベイズ確率
5分でわかるベイズ確率5分でわかるベイズ確率
5分でわかるベイズ確率hoxo_m
 

Destaque (20)

How to Develop Experiment-Oriented Programs
How to Develop Experiment-Oriented ProgramsHow to Develop Experiment-Oriented Programs
How to Develop Experiment-Oriented Programs
 
機械学習向けプログラミング言語の使い分け - RCO の場合
機械学習向けプログラミング言語の使い分け - RCO の場合機械学習向けプログラミング言語の使い分け - RCO の場合
機械学習向けプログラミング言語の使い分け - RCO の場合
 
Stochastic Gradient MCMC
Stochastic Gradient MCMCStochastic Gradient MCMC
Stochastic Gradient MCMC
 
高速・省メモリにlibsvm形式で ダンプする方法を研究してみた
高速・省メモリにlibsvm形式で ダンプする方法を研究してみた高速・省メモリにlibsvm形式で ダンプする方法を研究してみた
高速・省メモリにlibsvm形式で ダンプする方法を研究してみた
 
Introduction of “Fairness in Learning: Classic and Contextual Bandits”
Introduction of “Fairness in Learning: Classic and Contextual Bandits”Introduction of “Fairness in Learning: Classic and Contextual Bandits”
Introduction of “Fairness in Learning: Classic and Contextual Bandits”
 
Differential privacy without sensitivity [NIPS2016読み会資料]
Differential privacy without sensitivity [NIPS2016読み会資料]Differential privacy without sensitivity [NIPS2016読み会資料]
Differential privacy without sensitivity [NIPS2016読み会資料]
 
Conditional Image Generation with PixelCNN Decoders
Conditional Image Generation with PixelCNN DecodersConditional Image Generation with PixelCNN Decoders
Conditional Image Generation with PixelCNN Decoders
 
Interaction Networks for Learning about Objects, Relations and Physics
Interaction Networks for Learning about Objects, Relations and PhysicsInteraction Networks for Learning about Objects, Relations and Physics
Interaction Networks for Learning about Objects, Relations and Physics
 
Introduction of "TrailBlazer" algorithm
Introduction of "TrailBlazer" algorithmIntroduction of "TrailBlazer" algorithm
Introduction of "TrailBlazer" algorithm
 
Fast and Probvably Seedings for k-Means
Fast and Probvably Seedings for k-MeansFast and Probvably Seedings for k-Means
Fast and Probvably Seedings for k-Means
 
InfoGAN: Interpretable Representation Learning by Information Maximizing Gen...
InfoGAN: Interpretable Representation Learning by Information Maximizing Gen...InfoGAN: Interpretable Representation Learning by Information Maximizing Gen...
InfoGAN: Interpretable Representation Learning by Information Maximizing Gen...
 
Improving Variational Inference with Inverse Autoregressive Flow
Improving Variational Inference with Inverse Autoregressive FlowImproving Variational Inference with Inverse Autoregressive Flow
Improving Variational Inference with Inverse Autoregressive Flow
 
Fractality of Massive Graphs: Scalable Analysis with Sketch-Based Box-Coverin...
Fractality of Massive Graphs: Scalable Analysis with Sketch-Based Box-Coverin...Fractality of Massive Graphs: Scalable Analysis with Sketch-Based Box-Coverin...
Fractality of Massive Graphs: Scalable Analysis with Sketch-Based Box-Coverin...
 
Learning to learn by gradient descent by gradient descent
Learning to learn by gradient descent by gradient descentLearning to learn by gradient descent by gradient descent
Learning to learn by gradient descent by gradient descent
 
Value iteration networks
Value iteration networksValue iteration networks
Value iteration networks
 
Development and Experiment of Deep Learning with Caffe and maf
Development and Experiment of Deep Learning with Caffe and mafDevelopment and Experiment of Deep Learning with Caffe and maf
Development and Experiment of Deep Learning with Caffe and maf
 
Safe and Efficient Off-Policy Reinforcement Learning
Safe and Efficient Off-Policy Reinforcement LearningSafe and Efficient Off-Policy Reinforcement Learning
Safe and Efficient Off-Policy Reinforcement Learning
 
Dual Learning for Machine Translation (NIPS 2016)
Dual Learning for Machine Translation (NIPS 2016)Dual Learning for Machine Translation (NIPS 2016)
Dual Learning for Machine Translation (NIPS 2016)
 
Matching networks for one shot learning
Matching networks for one shot learningMatching networks for one shot learning
Matching networks for one shot learning
 
5分でわかるベイズ確率
5分でわかるベイズ確率5分でわかるベイズ確率
5分でわかるベイズ確率
 

Mais de Maruyama Tetsutaro

Mining of massive datasets chapter3
Mining of massive datasets chapter3Mining of massive datasets chapter3
Mining of massive datasets chapter3Maruyama Tetsutaro
 
業務に活かすデータサイエンスとは?
業務に活かすデータサイエンスとは?業務に活かすデータサイエンスとは?
業務に活かすデータサイエンスとは?Maruyama Tetsutaro
 
Ubuntuで最新パッケージを導入
Ubuntuで最新パッケージを導入Ubuntuで最新パッケージを導入
Ubuntuで最新パッケージを導入Maruyama Tetsutaro
 
Zshでデキるプロンプト
ZshでデキるプロンプトZshでデキるプロンプト
ZshでデキるプロンプトMaruyama Tetsutaro
 

Mais de Maruyama Tetsutaro (7)

Lambda and rundeck
Lambda and rundeckLambda and rundeck
Lambda and rundeck
 
Mining of massive datasets chapter3
Mining of massive datasets chapter3Mining of massive datasets chapter3
Mining of massive datasets chapter3
 
業務に活かすデータサイエンスとは?
業務に活かすデータサイエンスとは?業務に活かすデータサイエンスとは?
業務に活かすデータサイエンスとは?
 
日本の伝統色
日本の伝統色日本の伝統色
日本の伝統色
 
Gnuplotあれこれ
GnuplotあれこれGnuplotあれこれ
Gnuplotあれこれ
 
Ubuntuで最新パッケージを導入
Ubuntuで最新パッケージを導入Ubuntuで最新パッケージを導入
Ubuntuで最新パッケージを導入
 
Zshでデキるプロンプト
ZshでデキるプロンプトZshでデキるプロンプト
Zshでデキるプロンプト
 

配列数式