[gnumeric] Add PERCENTILE.EXC
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Add PERCENTILE.EXC
- Date: Mon, 15 Jun 2015 05:11:10 +0000 (UTC)
commit c10bb7a9a4d6579e2fbae773166623bccf8cee82
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Sun Jun 14 23:07:03 2015 -0600
Add PERCENTILE.EXC
2015-06-14 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (oo_func_map_in): Add PERCENTILE.EXC
* openoffice-write.c (odf_expr_func_handler): Export PERCENTILE.EXC
with Microsoft prefix
2015-06-14 Andreas J. Guelzow <aguelzow pyrshep ca>
* functions.c (help_percentile_exc): new
(gnumeric_percentile_exc): new
(stat_functions): connect the above
* plugin.xml.in: add PERCENTILE.EXC
NEWS | 2 +-
plugins/fn-stat/ChangeLog | 7 +++++
plugins/fn-stat/functions.c | 49 +++++++++++++++++++++++++++++++-
plugins/fn-stat/plugin.xml.in | 1 +
plugins/openoffice/ChangeLog | 6 ++++
plugins/openoffice/openoffice-read.c | 1 +
plugins/openoffice/openoffice-write.c | 1 +
7 files changed, 64 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index a000ec3..6e982b2 100644
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,7 @@ Andreas:
* Fix memory handling error on fuzzed sxc file. [#748535]
* Improve import/export of page layout from/to ODF.
* Improve function import to ODF. [#750627]
- * Add CONFIDENCE.T and QUARTILE.EXC.
+ * Add CONFIDENCE.T, PERCENTILE.EXC and QUARTILE.EXC.
Jean:
* Fix xlsx import of plot area manual layout. [#748016]
diff --git a/plugins/fn-stat/ChangeLog b/plugins/fn-stat/ChangeLog
index b7688bf..2a1ac23 100644
--- a/plugins/fn-stat/ChangeLog
+++ b/plugins/fn-stat/ChangeLog
@@ -1,5 +1,12 @@
2015-06-14 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * functions.c (help_percentile_exc): new
+ (gnumeric_percentile_exc): new
+ (stat_functions): connect the above
+ * plugin.xml.in: add PERCENTILE.EXC
+
+2015-06-14 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* functions.c (help_quartile_exc): new
(gnumeric_quartile_exc): new
(stat_functions): connect the above
diff --git a/plugins/fn-stat/functions.c b/plugins/fn-stat/functions.c
index a08c365..f1539c4 100644
--- a/plugins/fn-stat/functions.c
+++ b/plugins/fn-stat/functions.c
@@ -2828,7 +2828,7 @@ gnumeric_percentrank (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
/***************************************************************************/
static GnmFuncHelp const help_percentile[] = {
- { GNM_FUNC_HELP_NAME, F_("PERCENTILE:determines the 100* {k}-th percentile of the given data
points")},
+ { GNM_FUNC_HELP_NAME, F_("PERCENTILE:determines the 100* {k}-th percentile of the given data points
(Hyndman-Fan method 7: N-1 basis)")},
{ GNM_FUNC_HELP_ARG, F_("array:data points")},
{ GNM_FUNC_HELP_ARG, F_("k:which percentile to calculate")},
{ GNM_FUNC_HELP_NOTE, F_("If @{array} is empty, this function returns a #NUM! error.") },
@@ -2869,6 +2869,48 @@ gnumeric_percentile (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
/***************************************************************************/
+static GnmFuncHelp const help_percentile_exc[] = {
+ { GNM_FUNC_HELP_NAME, F_("PERCENTILE.EXC:determines the 100* {k}-th percentile of the given data
points (Hyndman-Fan method 6: N+1 basis)")},
+ { GNM_FUNC_HELP_ARG, F_("array:data points")},
+ { GNM_FUNC_HELP_ARG, F_("k:which percentile to calculate")},
+ { GNM_FUNC_HELP_NOTE, F_("If @{array} is empty, this function returns a #NUM! error.") },
+ { GNM_FUNC_HELP_NOTE, F_("If @{k} < 0 or @{k} > 1, this function returns a #NUM! error.")},
+ { GNM_FUNC_HELP_EXCEL, F_("This function is Excel compatible.") },
+ { GNM_FUNC_HELP_EXAMPLES, F_("Let us assume that the cells A1, A2, ..., A5 contain numbers 11.4,
17.3, 21.3, 25.9, and 40.1.") },
+ { GNM_FUNC_HELP_EXAMPLES, F_("Then PERCENTILE.EXC(A1:A5,0.42) equals 20.02.") },
+ { GNM_FUNC_HELP_SEEALSO, "PERCENTILE,QUARTILE,QUARTILE.EXC"},
+ { GNM_FUNC_HELP_END }
+};
+
+static GnmValue *
+gnumeric_percentile_exc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
+{
+ gnm_float *data;
+ GnmValue *result = NULL;
+ int n;
+
+ data = collect_floats_value (argv[0], ei->pos,
+ COLLECT_IGNORE_STRINGS |
+ COLLECT_IGNORE_BOOLS |
+ COLLECT_IGNORE_BLANKS |
+ COLLECT_SORT,
+ &n, &result);
+ if (!result) {
+ gnm_float p = value_get_as_float (argv[1]);
+ gnm_float res;
+ gnm_float fr = (p * (n + 1) - 1)/(n-1);
+
+ if (gnm_range_fractile_inter_sorted (data, n, &res, fr))
+ result = value_new_error_NUM (ei->pos);
+ else
+ result = value_new_float (res);
+ }
+
+ g_free (data);
+ return result;
+}
+/***************************************************************************/
+
static GnmFuncHelp const help_quartile[] = {
{ GNM_FUNC_HELP_NAME, F_("QUARTILE:the @{k}-th quartile of the data points (Hyndman-Fan method 7: N-1
basis)")},
{ GNM_FUNC_HELP_ARG, F_("array:data points")},
@@ -2922,7 +2964,7 @@ static GnmFuncHelp const help_quartile_exc[] = {
{ GNM_FUNC_HELP_EXCEL, F_("This function is Excel compatible.") },
{ GNM_FUNC_HELP_EXAMPLES, F_("Let us assume that the cells A1, A2, ..., A5 contain numbers 11.4,
17.3, 21.3, 25.9, and 40.1.") },
{ GNM_FUNC_HELP_EXAMPLES, F_("Then QUARTILE.EXC(A1:A5,1) equals 14.35.") },
- { GNM_FUNC_HELP_SEEALSO, "LARGE,MAX,MEDIAN,MIN,PERCENTILE,QUARTILE,SMALL"},
+ { GNM_FUNC_HELP_SEEALSO, "LARGE,MAX,MEDIAN,MIN,PERCENTILE,PERCENTILE.EXC,QUARTILE,SMALL"},
{ GNM_FUNC_HELP_END }
};
@@ -5281,6 +5323,9 @@ GnmFuncDescriptor const stat_functions[] = {
{ "percentile", "Af",
help_percentile, gnumeric_percentile, NULL, NULL, NULL,
GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
+ { "percentile.exc", "Af",
+ help_percentile_exc, gnumeric_percentile_exc, NULL, NULL, NULL,
+ GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_NO_TESTSUITE},
{ "percentrank", "Af|f",
help_percentrank, gnumeric_percentrank, NULL, NULL, NULL,
GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
diff --git a/plugins/fn-stat/plugin.xml.in b/plugins/fn-stat/plugin.xml.in
index c303ee1..ae87cf5 100644
--- a/plugins/fn-stat/plugin.xml.in
+++ b/plugins/fn-stat/plugin.xml.in
@@ -83,6 +83,7 @@
<function name="pareto"/>
<function name="pearson"/>
<function name="percentile"/>
+ <function name="percentile.exc"/>
<function name="percentrank"/>
<function name="permut"/>
<function name="permutationa"/>
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 418b97f..c952a47 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,11 @@
2015-06-14 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * openoffice-read.c (oo_func_map_in): Add PERCENTILE.EXC
+ * openoffice-write.c (odf_expr_func_handler): Export PERCENTILE.EXC
+ with Microsoft prefix
+
+2015-06-14 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* openoffice-read.c (oo_func_map_in): Add QUARTILE.EXC
* openoffice-write.c (odf_expr_func_handler): Export QUARTILE.EXC
with Microsoft prefix
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index ccc9056..0020b31 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -13208,6 +13208,7 @@ oo_func_map_in (GnmConventions const *convs, Workbook *scope,
{ "NORM.INV","NORMINV" },
{ "NORM.S.INV","NORMSINV" },
{ "PERCENTILE.INC","PERCENTILE" },
+ { "PERCENTILE.EXC","PERCENTILE.EXC" },
{ "PERCENTRANK.INC","PERCENTRANK" },
{ "POISSON.DIST","POISSON" },
{ "QUARTILE.INC","QUARTILE" },
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 498b6ba..0591ab7 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -2492,6 +2492,7 @@ odf_expr_func_handler (GnmConventionsOut *out, GnmExprFunction const *func)
{ "G_DURATION","PDURATION" },
{ "PEARSON","PEARSON" },
{ "PERCENTILE","PERCENTILE" },
+ { "PERCENTILE.EXC","COM.MICROSOFT.PERCENTILE.EXC" },
{ "PERCENTRANK","PERCENTRANK" },
{ "PERMUT","PERMUT" },
{ "PERMUTATIONA","PERMUTATIONA" },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]