[gnumeric] Add CONFIDENCE.T.



commit 313450a067d598a4c4101dc4fae3ae8139636bd6
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Sun Jun 14 14:59:30 2015 -0600

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

 NEWS                                  |    1 +
 plugins/fn-stat/ChangeLog             |    7 +++++
 plugins/fn-stat/functions.c           |   40 ++++++++++++++++++++++++++++++++-
 plugins/fn-stat/plugin.xml.in         |    1 +
 plugins/openoffice/ChangeLog          |    6 +++++
 plugins/openoffice/openoffice-read.c  |    1 +
 plugins/openoffice/openoffice-write.c |    8 ++++--
 7 files changed, 60 insertions(+), 4 deletions(-)
---
diff --git a/NEWS b/NEWS
index 0345c07..ace2a44 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +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.
 
 Jean:
        * Fix xlsx import of plot area manual layout. [#748016]
diff --git a/plugins/fn-stat/ChangeLog b/plugins/fn-stat/ChangeLog
index 44c596f..8c6e4d8 100644
--- a/plugins/fn-stat/ChangeLog
+++ b/plugins/fn-stat/ChangeLog
@@ -1,3 +1,10 @@
+2015-06-14  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * functions.c (help_confidence_t): new
+       (gnumeric_confidence_t): new
+       (stat_functions): connect the above
+       * plugin.xml.in: add CONFIDENCE.T
+
 2015-04-16  Morten Welinder <terra gnome org>
 
        * Release 1.12.22
diff --git a/plugins/fn-stat/functions.c b/plugins/fn-stat/functions.c
index 4a3c09c..36caf97 100644
--- a/plugins/fn-stat/functions.c
+++ b/plugins/fn-stat/functions.c
@@ -1748,7 +1748,7 @@ static GnmFuncHelp const help_confidence[] = {
        { GNM_FUNC_HELP_NOTE, F_("If @{size} is 0 this function returns a #DIV/0! error.")},
        { GNM_FUNC_HELP_EXCEL, F_("This function is Excel compatible.") },
        { GNM_FUNC_HELP_EXAMPLES, "=CONFIDENCE(0.05,1,33)" },
-       { GNM_FUNC_HELP_SEEALSO, "AVERAGE"},
+       { GNM_FUNC_HELP_SEEALSO, "AVERAGE,CONFIDENCE.T"},
        { GNM_FUNC_HELP_END }
 };
 
@@ -1759,6 +1759,8 @@ gnumeric_confidence (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        gnm_float stddev = value_get_as_float (argv[1]);
        gnm_float size = gnm_fake_floor (value_get_as_float (argv[2]));
 
+       if (size == 0.)
+               return value_new_error_DIV0 (ei->pos);
        if (size <= 0 || stddev <= 0)
                return value_new_error_NUM (ei->pos);
 
@@ -1767,6 +1769,39 @@ gnumeric_confidence (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
 
 /***************************************************************************/
 
+static GnmFuncHelp const help_confidence_t[] = {
+       { GNM_FUNC_HELP_NAME, F_("CONFIDENCE.T:margin of error of a confidence interval for the "
+                                "population mean using the Student's t-distribution")},
+       { GNM_FUNC_HELP_ARG, F_("alpha:significance level")},
+       { GNM_FUNC_HELP_ARG, F_("stddev:sample standard deviation")},
+       { GNM_FUNC_HELP_ARG, F_("size:sample size")},
+       { GNM_FUNC_HELP_NOTE, F_("If @{stddev} < 0 or = 0 this function returns a #NUM! error.") },
+       { GNM_FUNC_HELP_NOTE, F_("If @{size} is non-integer it is truncated.") },
+       { GNM_FUNC_HELP_NOTE, F_("If @{size} < 1 this function returns a #NUM! error.") },
+       { GNM_FUNC_HELP_NOTE, F_("If @{size} is 1 this function returns a #DIV/0! error.")},
+       { GNM_FUNC_HELP_EXCEL, F_("This function is Excel compatible.") },
+       { GNM_FUNC_HELP_EXAMPLES, "=CONFIDENCE.T(0.05,1,33)" },
+       { GNM_FUNC_HELP_SEEALSO, "AVERAGE,CONFIDENCE"},
+       { GNM_FUNC_HELP_END }
+};
+
+static GnmValue *
+gnumeric_confidence_t (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
+{
+       gnm_float x = value_get_as_float (argv[0]);
+       gnm_float stddev = value_get_as_float (argv[1]);
+       gnm_float size = gnm_fake_floor (value_get_as_float (argv[2]));
+
+       if (size == 1.)
+               return value_new_error_DIV0 (ei->pos);
+       if (size <= 1 || stddev <= 0)
+               return value_new_error_NUM (ei->pos);
+
+       return value_new_float (-qt (x / 2, size - 1, TRUE, FALSE) * (stddev / gnm_sqrt (size)));
+}
+
+/***************************************************************************/
+
 static GnmFuncHelp const help_standardize[] = {
        { GNM_FUNC_HELP_NAME, F_("STANDARDIZE:z-score of a value")},
        { GNM_FUNC_HELP_ARG, F_("x:value")},
@@ -5052,6 +5087,9 @@ GnmFuncDescriptor const stat_functions[] = {
        { "confidence",   "fff",
          help_confidence, gnumeric_confidence, NULL, NULL, NULL,
          GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
+       { "confidence.t",   "fff",
+         help_confidence_t, gnumeric_confidence_t, NULL, NULL, NULL,
+         GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE,  GNM_FUNC_TEST_STATUS_NO_TESTSUITE},
        { "correl",       "AA",
          help_correl, gnumeric_correl, 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 bd13392..40e664a 100644
--- a/plugins/fn-stat/plugin.xml.in
+++ b/plugins/fn-stat/plugin.xml.in
@@ -26,6 +26,7 @@
                                <function name="chiinv"/>
                                <function name="chitest"/>
                                <function name="confidence"/>
+                               <function name="confidence.t"/>
                                <function name="correl"/>
                                <function name="count"/>
                                <function name="counta"/>
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index e43b905..cda163b 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,9 @@
+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
+
 2015-06-13  Andreas J. Guelzow <aguelzow pyrshep ca>
 
        * openoffice-read.c (odf_func_dist4_handler): new
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 1fca37c..f9ed563 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -13191,6 +13191,7 @@ oo_func_map_in (GnmConventions const *convs, Workbook *scope,
                { "CHISQ.INV.RT","CHIINV" },
                { "CHISQ.TEST","CHITEST" },
                { "CONFIDENCE.NORM","CONFIDENCE" },
+               { "CONFIDENCE.T","CONFIDENCE.T" },
                { "COVARIANCE.P","COVAR" },
                { "COVARIANCE.S","COVARIANCE.S" },
                { "EXPON.DIST","EXPONDIST" },
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 89e0159..8c389e7 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -2211,8 +2211,9 @@ odf_expr_func_handler (GnmConventionsOut *out, GnmExprFunction const *func)
                /* ORG.GNUMERIC. So we need not list gnumeric unique names or those that  */
                /* come from unknown plugins                                              */
 
-               /* The following are functions that exist in OpenFormula, this listing is */
-               /* alphabetical by the second entry, the OpenFormula name.                */
+               /* The following are functions that exist in OpenFormula or with anbother */
+               /* known prefix. This listing is */
+               /* alphabetical by the second entry, the OpenFormula or foreign name (w/o prefix). */
 
                { "ABS","ABS" },
                { "ACCRINT","ACCRINT" },
@@ -2265,7 +2266,8 @@ odf_expr_func_handler (GnmConventionsOut *out, GnmExprFunction const *func)
                { "CLEAN","CLEAN" },
                { "CODE","CODE" },
                { "COLUMN","COLUMN" },
-               { "COLUMNS","COLUMNS" },
+               { "COLUMNS","COLUMNS" }
+,              { "CONFIDENCE.T","COM.MICROSOFT.CONFIDENCE.T" },
                { "COMBIN","COMBIN" },
                { "COMBINA","COMBINA" },
                { "COMPLEX","COMPLEX" },


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