mirror of https://github.com/apache/poi.git
add PEARSON function
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1901688 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
41dfbd67c5
commit
1bae0a43bf
|
@ -292,7 +292,7 @@ public final class FunctionEval {
|
|||
// 309: FORECAST
|
||||
// 310: FTEST
|
||||
retval[311] = new Intercept();
|
||||
// 312: PEARSON
|
||||
retval[312] = Correl.instance;
|
||||
// 313: RSQ
|
||||
// 314: STEYX
|
||||
retval[315] = new Slope();
|
||||
|
|
|
@ -48,6 +48,18 @@ final class TestCorrel {
|
|||
}
|
||||
}
|
||||
|
||||
//https://support.microsoft.com/en-us/office/pearson-function-0c3e30fc-e5af-49c4-808a-3ef66e034c18
|
||||
@Test
|
||||
void testPearsonExample1() throws IOException {
|
||||
try (HSSFWorkbook wb = initWorkbook2()) {
|
||||
HSSFSheet sheet = wb.getSheetAt(0);
|
||||
HSSFRow row = sheet.getRow(0);
|
||||
HSSFCell cell = row.createCell(100);
|
||||
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
|
||||
assertDouble(fe, cell, "CORREL(A2:A6,B2:B6)", 0.699379, 0.0000005);
|
||||
assertDouble(fe, cell, "PEARSON(A2:A6,B2:B6)", 0.699379, 0.0000005);
|
||||
}
|
||||
}
|
||||
@Test
|
||||
void testBlankValue() throws IOException {
|
||||
try (HSSFWorkbook wb = initWorkbook1(null)) {
|
||||
|
@ -97,4 +109,16 @@ final class TestCorrel {
|
|||
addRow(sheet, 5, 6, 17);
|
||||
return wb;
|
||||
}
|
||||
|
||||
private HSSFWorkbook initWorkbook2() {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet sheet = wb.createSheet();
|
||||
addRow(sheet, 0, "Independent values", "Dependent values");
|
||||
addRow(sheet, 1, 9, 10);
|
||||
addRow(sheet, 2, 7, 6);
|
||||
addRow(sheet, 3, 5, 1);
|
||||
addRow(sheet, 4, 3, 5);
|
||||
addRow(sheet, 5, 1, 3);
|
||||
return wb;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue