IBM InfoSphere Streams Version 4.1.0
SPL File Correlation.spl
SPL standard and specialized toolkits > com.ibm.streams.financial 2.0.0 > com.ibm.streams.financial.utility > Correlation.spl
Content
- Functions
- correlationCoefficient(list<float32>, list<float32>): An SPL function is provided in the Financial Services Toolkit for computing the Coefficient of Correlation between two series of variables.
Functions
float32 correlationCoefficient(list<float32> series1, list<float32> series2)
An SPL function is provided in the Financial Services Toolkit for computing the Coefficient of Correlation between two series of variables.
The source code for the correlationCoefficient function can be found in the following file within your installed environment: $STREAMS_INSTALL/toolkits/com.ibm.streams.financial/com.ibm.streams.financial/utility/Correlation.spl.
Note: The two parameters must be lists that have an equal number of members.
Examples
This example demonstrates how to invoke the Correlation function.
use com.ibm.streams.financial.utility::*;
composite CCExample {
graph
stream<list<flaot32> series1> Series1Source = FileSource(){
param
file: "series1.date";
format: csv;
initDelay: 5fl;
}
stream<list<float32> series2> Series2Source = FileSource(){
param
file: "series2.dat";
format: csv;
initDelay: 5fl;
}
stream<list<float32> s1, list<float32> s2> JoinedSeries =
Barrier(Series1Source; Series2Source) {
output
JoinedSeries: s1 = series1, s2 = series2;
}
stream<float32 cc> CC = Functor(JoinedSeries){
param
filter: true;
output
CC: cc = correlationCoefficient(s1, s2);
}
() as SinkOp1 = FileSink(CC){
param
file: "CC.result";
format: csv;
flush: 1u;
writePunctuations: false;
}
}
Parameters
- series1: A list<float32> value, which contains a series of variables.
- series2: A list<float32> value, which contains a series of variables.
Returns
- float32