[gnumeric] Add QUARTILE.EXC.



commit 71fb92b329bc37a68b5373c4136b02b33b763879
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Sun Jun 14 22:11:00 2015 -0600

    Add QUARTILE.EXC.
    
    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
    
    2015-06-14  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * functions.c (help_quartile_exc): new
        (gnumeric_quartile_exc): new
        (stat_functions): connect the above
        * plugin.xml.in: add QUARTILE.EXC

 NEWS                                  |    2 +-
 plugins/fn-stat/ChangeLog             |    7 ++++
 plugins/fn-stat/functions.c           |   50 +++++++++++++++++++++++++++++++-
 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, 65 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index ace2a44..a000ec3 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.
+       * Add CONFIDENCE.T 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 8c6e4d8..b7688bf 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_quartile_exc): new
+       (gnumeric_quartile_exc): new
+       (stat_functions): connect the above
+       * plugin.xml.in: add QUARTILE.EXC
+
+2015-06-14  Andreas J. Guelzow <aguelzow pyrshep ca>
+
        * functions.c (help_confidence_t): new
        (gnumeric_confidence_t): new
        (stat_functions): connect the above
diff --git a/plugins/fn-stat/functions.c b/plugins/fn-stat/functions.c
index 36caf97..a08c365 100644
--- a/plugins/fn-stat/functions.c
+++ b/plugins/fn-stat/functions.c
@@ -2870,7 +2870,7 @@ gnumeric_percentile (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
 /***************************************************************************/
 
 static GnmFuncHelp const help_quartile[] = {
-       { GNM_FUNC_HELP_NAME, F_("QUARTILE:the @{k}-th quartile of the data points")},
+       { 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")},
        { GNM_FUNC_HELP_ARG, F_("quart:a number from 0 to 4, indicating which quartile to calculate")},
        { GNM_FUNC_HELP_NOTE, F_("If @{array} is empty, this function returns a #NUM! error.") },
@@ -2879,7 +2879,7 @@ static GnmFuncHelp const help_quartile[] = {
        { 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(A1:A5,1) equals 17.3.") },
-       { GNM_FUNC_HELP_SEEALSO, "LARGE,MAX,MEDIAN,MIN,PERCENTILE,SMALL"},
+       { GNM_FUNC_HELP_SEEALSO, "LARGE,MAX,MEDIAN,MIN,PERCENTILE,QUARTILE.EXC,SMALL"},
        { GNM_FUNC_HELP_END }
 };
 
@@ -2912,6 +2912,49 @@ gnumeric_quartile (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
 
 /***************************************************************************/
 
+static GnmFuncHelp const help_quartile_exc[] = {
+       { GNM_FUNC_HELP_NAME, F_("QUARTILE.EXC:the @{k}-th quartile of the data points (Hyndman-Fan method 6: 
N+1 basis)")},
+       { GNM_FUNC_HELP_ARG, F_("array:data points")},
+       { GNM_FUNC_HELP_ARG, F_("quart:a number from 1 to 3, indicating which quartile to calculate")},
+       { GNM_FUNC_HELP_NOTE, F_("If @{array} is empty, this function returns a #NUM! error.") },
+       { GNM_FUNC_HELP_NOTE, F_("If @{quart} < 0 or @{quart} > 4, this function returns a #NUM! error. If 
@{quart} = 0, the smallest value of @{array} to be returned.") },
+       { GNM_FUNC_HELP_NOTE, F_("If @{quart} is not an integer, it is truncated.")},
+       { 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_END }
+};
+
+static GnmValue *
+gnumeric_quartile_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 q = gnm_fake_floor (value_get_as_float (argv[1]));
+               gnm_float res;
+               gnm_float fr = ((q / 4.0) * (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_ftest[] = {
        { GNM_FUNC_HELP_NAME, F_("FTEST:p-value for the two-tailed hypothesis test comparing the "
                                 "variances of two populations")},
@@ -5253,6 +5296,9 @@ GnmFuncDescriptor const stat_functions[] = {
        { "quartile",     "Af",
          help_quartile, gnumeric_quartile, NULL, NULL, NULL,
          GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
+       { "quartile.exc",     "Af",
+         help_quartile_exc, gnumeric_quartile_exc, NULL, NULL, NULL,
+         GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_NO_TESTSUITE},
        { "rank",         "fr|b",
          help_rank, gnumeric_rank, 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 40e664a..c303ee1 100644
--- a/plugins/fn-stat/plugin.xml.in
+++ b/plugins/fn-stat/plugin.xml.in
@@ -89,6 +89,7 @@
                                <function name="poisson"/>
                                <function name="prob"/>
                                <function name="quartile"/>
+                               <function name="quartile.exc"/>
                                <function name="rank"/>
                                <function name="rank.avg"/>
                                <function name="rayleigh"/>
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index cda163b..418b97f 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 QUARTILE.EXC
+       * openoffice-write.c (odf_expr_func_handler): Export QUARTILE.EXC
+       with Microsoft prefix
+
+2015-06-14  Andreas J. Guelzow <aguelzow pyrshep ca>
+
        * openoffice-read.c (oo_func_map_in): Add CONFIDENCE.T
        * openoffice-write.c (odf_expr_func_handler): Export CONFIDENCE.T
        with Microsoft prefix
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index f9ed563..ccc9056 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -13211,6 +13211,7 @@ oo_func_map_in (GnmConventions const *convs, Workbook *scope,
                { "PERCENTRANK.INC","PERCENTRANK" },
                { "POISSON.DIST","POISSON" },
                { "QUARTILE.INC","QUARTILE" },
+               { "QUARTILE.EXC","QUARTILE.EXC" },
                { "RANK.EQ","RANK" },
                { "STDEV.S","STDEV" },
                { "STDEV.P","STDEVP" },
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 8c389e7..498b6ba 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -2509,6 +2509,7 @@ odf_expr_func_handler (GnmConventionsOut *out, GnmExprFunction const *func)
                { "PROPER","PROPER" },
                { "PV","PV" },
                { "QUARTILE","QUARTILE" },
+               { "QUARTILE.EXC","COM.MICROSOFT.QUARTILE.EXC" },
                { "QUOTIENT","QUOTIENT" },
                { "RADIANS","RADIANS" },
                { "RAND","RAND" },


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]