[gnumeric] Add single sample t-test.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Add single sample t-test.
- Date: Mon, 11 Jun 2012 19:17:17 +0000 (UTC)
commit 53a2ffc084dacb49e3600811d80132ee2f13e9e1
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Mon Jun 11 13:15:41 2012 -0600
Add single sample t-test.
2012-06-11 Andreas J. Guelzow <aguelzow pyrshep ca>
* component/Gnumeric-embed.xml.in: add ToolsOneMeanTest
* src/GNOME_Gnumeric-gtk.xml.in: ditto
* src/wbc-gtk-actions.c (cb_tools_one_mean_test): new
(actions): add ToolsOneMeanTest
2012-06-11 Andreas J. Guelzow <aguelzow pyrshep ca>
* analysis-one-mean-test.c: new
* analysis-one-mean-test.h: new
* Makefile.am: add the above
2012-06-11 Andreas J. Guelzow <aguelzow pyrshep ca>
* one-mean-test.ui: new
* dialog-analysis-tool-one-mean.c: new
* Makefile.am: add the above
* help.h (GNUMERIC_HELP_LINK_ONE_MEAN): new
* dialogs.h (dialog_one_mean_test_tool): new
ChangeLog | 7 +
NEWS | 1 +
component/Gnumeric-embed.xml.in | 1 +
po-functions/ChangeLog | 5 +
po-functions/POTFILES.in | 3 +
po/ChangeLog | 5 +
po/POTFILES.in | 3 +
src/GNOME_Gnumeric-gtk.xml.in | 1 +
src/dialogs/ChangeLog | 8 +
src/dialogs/Makefile.am | 2 +
src/dialogs/dialog-analysis-tool-one-mean.c | 253 +++++++++++++++++
src/dialogs/dialogs.h | 1 +
src/dialogs/help.h | 3 +
src/dialogs/one-mean-test.ui | 388 +++++++++++++++++++++++++++
src/tools/ChangeLog | 6 +
src/tools/Makefile.am | 2 +
src/tools/analysis-one-mean-test.c | 178 ++++++++++++
src/tools/analysis-one-mean-test.h | 49 ++++
src/wbc-gtk-actions.c | 4 +
19 files changed, 920 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5bbe9a8..8cf6e87 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-06-11 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * component/Gnumeric-embed.xml.in: add ToolsOneMeanTest
+ * src/GNOME_Gnumeric-gtk.xml.in: ditto
+ * src/wbc-gtk-actions.c (cb_tools_one_mean_test): new
+ (actions): add ToolsOneMeanTest
+
2012-06-10 Jean Brefort <jean brefort normalesup org>
* src/wbc-gtk.c (cb_scroll_wheel): make mouse wheel scrolling work
diff --git a/NEWS b/NEWS
index f688779..75cf9ba 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,7 @@ Andreas:
* Fix space handling on ODF import. [Part of #676535]
* Fix TIME and add ODF.TIME. [#676596]
* Fix Wilcoxon Mann Whitney Test in the presence of empty cells.
+ * Add single sample t-test.
Jean:
* Fix graph series headers when a multiple selection is used. [#675913]
diff --git a/component/Gnumeric-embed.xml.in b/component/Gnumeric-embed.xml.in
index da9bc14..e98c7de 100644
--- a/component/Gnumeric-embed.xml.in
+++ b/component/Gnumeric-embed.xml.in
@@ -231,6 +231,7 @@
<separator/>
<menu name="StatisticsOneSample" action="MenuStatisticsOneSample">
<menuitem action="ToolsNormalityTests"/>
+ <menuitem action="ToolsOneMeanTest"/>
<menu name="ToolOneMedian" action="MenuToolOneMedian">
<menuitem action="ToolsOneMedianSignTest"/>
<menuitem action="ToolsOneMedianWilcoxonSignedRank"/>
diff --git a/po-functions/ChangeLog b/po-functions/ChangeLog
index 3135468..b01bd4f 100644
--- a/po-functions/ChangeLog
+++ b/po-functions/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-11 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * POTFILES.in: add src/dialogs/dialog-analysis-tool-one-mean.c,
+ src/dialogs/one-mean-test.ui and src/tools/analysis-one-mean-test.c
+
2012-05-01 Andreas J. Guelzow <aguelzow pyrshep ca>
* README.translators: add information
diff --git a/po-functions/POTFILES.in b/po-functions/POTFILES.in
index cd223cb..7df650a 100644
--- a/po-functions/POTFILES.in
+++ b/po-functions/POTFILES.in
@@ -81,6 +81,7 @@ src/dialogs/dialog-analysis-tool-chi-squared.c
src/dialogs/dialog-analysis-tool-frequency.c
src/dialogs/dialog-analysis-tool-kaplan-meier.c
src/dialogs/dialog-analysis-tool-normality.c
+src/dialogs/dialog-analysis-tool-one-mean.c
src/dialogs/dialog-analysis-tool-principal-components.c
src/dialogs/dialog-analysis-tool-sign-test.c
src/dialogs/dialog-analysis-tool-wilcoxon-mann-whitney.c
@@ -185,6 +186,7 @@ src/dialogs/dialog-zoom.c
[type: gettext/glade]src/dialogs/merge.ui
[type: gettext/glade]src/dialogs/moving-averages.ui
[type: gettext/glade]src/dialogs/normality-tests.ui
+[type: gettext/glade]src/dialogs/one-mean-test.ui
[type: gettext/glade]src/dialogs/paste-special.ui
[type: gettext/glade]src/dialogs/plugin-manager.ui
[type: gettext/glade]src/dialogs/preferences.ui
@@ -287,6 +289,7 @@ src/tools/analysis-frequency.c
src/tools/analysis-histogram.c
src/tools/analysis-kaplan-meier.c
src/tools/analysis-normality.c
+src/tools/analysis-one-mean-test.c
src/tools/analysis-principal-components.c
src/tools/analysis-sign-test.c
src/tools/analysis-signed-rank-test.c
diff --git a/po/ChangeLog b/po/ChangeLog
index bba4d43..3562101 100644
--- a/po/ChangeLog
+++ b/po/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-11 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * POTFILES.in: add src/dialogs/dialog-analysis-tool-one-mean.c,
+ src/dialogs/one-mean-test.ui and src/tools/analysis-one-mean-test.c
+
2012-04-21 Morten Welinder <terra gnome org>
* Release 1.11.3
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0fa6f70..150d4b6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -140,6 +140,7 @@ src/dialogs/dialog-analysis-tool-chi-squared.c
src/dialogs/dialog-analysis-tool-frequency.c
src/dialogs/dialog-analysis-tool-kaplan-meier.c
src/dialogs/dialog-analysis-tool-normality.c
+src/dialogs/dialog-analysis-tool-one-mean.c
src/dialogs/dialog-analysis-tool-principal-components.c
src/dialogs/dialog-analysis-tool-sign-test.c
src/dialogs/dialog-analysis-tool-wilcoxon-mann-whitney.c
@@ -244,6 +245,7 @@ src/dialogs/dialog-zoom.c
[type: gettext/glade]src/dialogs/merge.ui
[type: gettext/glade]src/dialogs/moving-averages.ui
[type: gettext/glade]src/dialogs/normality-tests.ui
+[type: gettext/glade]src/dialogs/one-mean-test.ui
[type: gettext/glade]src/dialogs/paste-special.ui
[type: gettext/glade]src/dialogs/plugin-manager.ui
[type: gettext/glade]src/dialogs/preferences.ui
@@ -346,6 +348,7 @@ src/tools/analysis-frequency.c
src/tools/analysis-histogram.c
src/tools/analysis-kaplan-meier.c
src/tools/analysis-normality.c
+src/tools/analysis-one-mean-test.c
src/tools/analysis-principal-components.c
src/tools/analysis-sign-test.c
src/tools/analysis-signed-rank-test.c
diff --git a/src/GNOME_Gnumeric-gtk.xml.in b/src/GNOME_Gnumeric-gtk.xml.in
index a5b2392..17dd237 100644
--- a/src/GNOME_Gnumeric-gtk.xml.in
+++ b/src/GNOME_Gnumeric-gtk.xml.in
@@ -236,6 +236,7 @@
<separator/>
<menu name="StatisticsOneSample" action="MenuStatisticsOneSample">
<menuitem action="ToolsNormalityTests"/>
+ <menuitem action="ToolsOneMeanTest"/>
<menu name="ToolOneMedian" action="MenuToolOneMedian">
<menuitem action="ToolsOneMedianSignTest"/>
<menuitem action="ToolsOneMedianWilcoxonSignedRank"/>
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 7f792d9..65b1972 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,11 @@
+2012-06-11 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * one-mean-test.ui: new
+ * dialog-analysis-tool-one-mean.c: new
+ * Makefile.am: add the above
+ * help.h (GNUMERIC_HELP_LINK_ONE_MEAN): new
+ * dialogs.h (dialog_one_mean_test_tool): new
+
2012-05-29 Morten Welinder <terra gnome org>
* dialog-cell-format-cond.c (c_fmt_dialog_get_condition): Use
diff --git a/src/dialogs/Makefile.am b/src/dialogs/Makefile.am
index fd46f85..19d076c 100644
--- a/src/dialogs/Makefile.am
+++ b/src/dialogs/Makefile.am
@@ -31,6 +31,7 @@ base_files = \
dialog-analysis-tool-frequency.c \
dialog-analysis-tool-kaplan-meier.c \
dialog-analysis-tool-normality.c \
+ dialog-analysis-tool-one-mean.c \
dialog-analysis-tool-principal-components.c \
dialog-analysis-tool-sign-test.c \
dialog-analysis-tool-wilcoxon-mann-whitney.c \
@@ -145,6 +146,7 @@ embedded_uis = \
merge.ui \
moving-averages.ui \
normality-tests.ui \
+ one-mean-test.ui \
paste-special.ui \
plugin-manager.ui \
preferences.ui \
diff --git a/src/dialogs/dialog-analysis-tool-one-mean.c b/src/dialogs/dialog-analysis-tool-one-mean.c
new file mode 100644
index 0000000..bd9ae52
--- /dev/null
+++ b/src/dialogs/dialog-analysis-tool-one-mean.c
@@ -0,0 +1,253 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * dialog-analysis-tool-one-mean.c:
+ *
+ * Authors:
+ * Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ * (C) Copyright 2012 by Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gnumeric-config.h>
+#include <glib/gi18n-lib.h>
+#include <gnumeric.h>
+#include "dialogs.h"
+#include "analysis-one-mean-test.h"
+#include "analysis-tools.h"
+
+#include <workbook.h>
+#include <workbook-control.h>
+#include <wbc-gtk.h>
+#include <workbook-view.h>
+#include <gui-util.h>
+#include <parse-util.h>
+#include <gnm-format.h>
+#include <tool-dialogs.h>
+#include <dao-gui-utils.h>
+#include <sheet.h>
+#include <expr.h>
+#include <number-match.h>
+#include <ranges.h>
+#include <selection.h>
+#include <value.h>
+#include <commands.h>
+#include "help.h"
+
+#include <widgets/gnm-dao.h>
+#include <widgets/gnumeric-expr-entry.h>
+
+#include <string.h>
+#include <gtk/gtk.h>
+
+#define ONE_MEAN_TEST_KEY "analysistools-one-mean-test-dialog"
+
+static char const * const grouped_by_group[] = {
+ "grouped_by_row",
+ "grouped_by_col",
+ "grouped_by_area",
+ NULL
+};
+
+typedef struct {
+ GenericToolState base;
+ GtkWidget *alpha_entry;
+ GtkWidget *mean_entry;
+} OneeMeanTestToolState;
+
+/**
+ * one_mean_test_tool_update_common_sensitivity_cb:
+ * @dummy:
+ * @state:
+ *
+ * Update the dialog widgets sensitivity
+ **/
+static gboolean
+one_mean_test_tool_update_common_sensitivity_cb (OneeMeanTestToolState *state)
+{
+ gnm_float alpha;
+ gnm_float mean;
+ gboolean err;
+
+ /* Checking Mean*/
+ err = entry_to_float
+ (GTK_ENTRY (state->mean_entry), &mean, FALSE);
+ if (err) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning),
+ _("The predicted mean should be a number."));
+ gtk_widget_set_sensitive (state->base.ok_button, FALSE);
+ return FALSE;
+ }
+
+ /* Checking Alpha*/
+ alpha = gtk_spin_button_get_value
+ (GTK_SPIN_BUTTON (state->alpha_entry));
+ if (!(alpha > 0 && alpha < 1)) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning),
+ _("The alpha value should "
+ "be a number between 0 and 1."));
+ gtk_widget_set_sensitive (state->base.ok_button, FALSE);
+ return FALSE;
+ }
+
+ /* Checking Output Page */
+ if (!gnm_dao_is_ready (GNM_DAO (state->base.gdao))) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning),
+ _("The output specification "
+ "is invalid."));
+ gtk_widget_set_sensitive (state->base.ok_button, FALSE);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+
+
+/************************************************************************************/
+
+/**
+ * one_mean_test_tool_ok_clicked_cb:
+ * @button:
+ * @state:
+ *
+ * Retrieve the information from the dialog and call the one_mean_test_tool.
+ * Note that we assume that the ok_button is only active if the entry fields
+ * contain sensible data.
+ **/
+static void
+one_mean_test_tool_ok_clicked_cb (G_GNUC_UNUSED GtkWidget *button,
+ OneeMeanTestToolState *state)
+{
+ data_analysis_output_t *dao;
+ GtkWidget *w;
+ analysis_tools_data_one_mean_test_t *data;
+
+ data = g_new0 (analysis_tools_data_one_mean_test_t, 1);
+ dao = parse_output ((GenericToolState *)state, NULL);
+
+ data->base.input = gnm_expr_entry_parse_as_list (
+ GNM_EXPR_ENTRY (state->base.input_entry), state->base.sheet);
+ data->base.group_by = gnm_gui_group_value (state->base.gui, grouped_by_group);
+
+ w = go_gtk_builder_get_widget (state->base.gui, "labels_button");
+ data->base.labels = gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (w));
+
+ entry_to_float
+ (GTK_ENTRY (state->mean_entry), &data->mean, FALSE);
+ data->alpha = gtk_spin_button_get_value
+ (GTK_SPIN_BUTTON (state->alpha_entry));
+
+ if (!cmd_analysis_tool (WORKBOOK_CONTROL (state->base.wbcg),
+ state->base.sheet,
+ dao, data, analysis_tool_one_mean_test_engine,
+ TRUE))
+ gtk_widget_destroy (state->base.dialog);
+
+ return;
+}
+
+/**
+ * one_mean_test_tool_update_sensitivity_cb:
+ * @dummy:
+ * @state:
+ *
+ * Update the dialog widgets sensitivity
+ **/
+static void
+one_mean_test_tool_update_sensitivity_cb (G_GNUC_UNUSED GtkWidget *dummy,
+ OneeMeanTestToolState *state)
+{
+ GSList *input_range;
+
+ /* Checking first input range*/
+ input_range = gnm_expr_entry_parse_as_list
+ (GNM_EXPR_ENTRY (state->base.input_entry),
+ state->base.sheet);
+ if (input_range == NULL) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning),
+ (state->base.input_entry_2 == NULL)
+ ? _("The input range is invalid.")
+ : _("The first input range is invalid."));
+ gtk_widget_set_sensitive (state->base.ok_button, FALSE);
+ return;
+ } else
+ range_list_destroy (input_range);
+
+ if (one_mean_test_tool_update_common_sensitivity_cb (state)) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning), "");
+ gtk_widget_set_sensitive (state->base.ok_button, TRUE);
+ }
+
+}
+
+/**
+ * dialog_one_mean_test_tool:
+ *
+ **/
+int
+dialog_one_mean_test_tool (WBCGtk *wbcg, Sheet *sheet)
+{
+ char const * plugins[] = { "Gnumeric_fnstat",
+ "Gnumeric_fnlogical",
+ "Gnumeric_fnmath",
+ "Gnumeric_fninfo",
+ NULL};
+ OneeMeanTestToolState *state;
+
+ if ((wbcg == NULL) ||
+ gnm_check_for_plugins_missing (plugins, wbcg_toplevel (wbcg)))
+ return 1;
+
+ /* Only pop up one copy per workbook */
+ if (gnumeric_dialog_raise_if_exists (wbcg, ONE_MEAN_TEST_KEY))
+ return 0;
+
+ state = g_new0 (OneeMeanTestToolState, 1);
+
+ if (dialog_tool_init (&state->base, wbcg, sheet,
+ GNUMERIC_HELP_LINK_ONE_MEAN,
+ "one-mean-test.ui", "One-Mean-Test",
+ _("Could not create the Student-t Test Tool dialog."),
+ ONE_MEAN_TEST_KEY,
+ G_CALLBACK (one_mean_test_tool_ok_clicked_cb),
+ NULL,
+ G_CALLBACK (one_mean_test_tool_update_sensitivity_cb),
+ 0))
+ return 0;
+
+
+ state->alpha_entry = tool_setup_update
+ (&state->base, "alpha-entry",
+ G_CALLBACK (one_mean_test_tool_update_sensitivity_cb),
+ state);
+ state->mean_entry = tool_setup_update
+ (&state->base, "mean-entry",
+ G_CALLBACK (one_mean_test_tool_update_sensitivity_cb),
+ state);
+
+ int_to_entry (GTK_ENTRY (state->mean_entry), 0);
+ float_to_entry (GTK_ENTRY (state->alpha_entry), 0.05);
+
+ gnm_dao_set_put (GNM_DAO (state->base.gdao), TRUE, TRUE);
+ one_mean_test_tool_update_sensitivity_cb (NULL, state);
+ tool_load_selection ((GenericToolState *)state, TRUE);
+
+ return 0;
+
+}
diff --git a/src/dialogs/dialogs.h b/src/dialogs/dialogs.h
index 39ad498..4e07834 100644
--- a/src/dialogs/dialogs.h
+++ b/src/dialogs/dialogs.h
@@ -100,6 +100,7 @@ int dialog_histogram_tool (WBCGtk *wbcg, Sheet *sheet);
int dialog_frequency_tool (WBCGtk *wbcg, Sheet *sheet);
int dialog_kaplan_meier_tool (WBCGtk *wbcg, Sheet *sheet);
int dialog_normality_tool (WBCGtk *wbcg, Sheet *sheet);
+int dialog_one_mean_test_tool (WBCGtk *wbcg, Sheet *sheet);
int dialog_chi_square_tool (WBCGtk *wbcg, Sheet *sheet, gboolean independence);
int dialog_principal_components_tool (WBCGtk *wbcg, Sheet *sheet);
int dialog_wilcoxon_m_w_tool (WBCGtk *wbcg, Sheet *sheet);
diff --git a/src/dialogs/help.h b/src/dialogs/help.h
index cf03698..a2d2e9d 100644
--- a/src/dialogs/help.h
+++ b/src/dialogs/help.h
@@ -161,6 +161,9 @@
/* dialog-analysis-tool-kaplan-meier.c */
#define GNUMERIC_HELP_LINK_KAPLAN_MEIER "kaplan-meier-tool"
+/* dialog-analysis-tool-sign-test.c */
+#define GNUMERIC_HELP_LINK_ONE_MEAN "one-mean-tool"
+
/* dialog-analysis-tool-normality.c */
#define GNUMERIC_HELP_LINK_NORMALITY "normality-tool"
diff --git a/src/dialogs/one-mean-test.ui b/src/dialogs/one-mean-test.ui
new file mode 100644
index 0000000..cfc7528
--- /dev/null
+++ b/src/dialogs/one-mean-test.ui
@@ -0,0 +1,388 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkDialog" id="One-Mean-Test">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Student-t Test</property>
+ <property name="type_hint">normal</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="hbuttonbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="helpbutton">
+ <property name="label">gtk-help</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="cancelbutton">
+ <property name="label">gtk-cancel</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="okbutton">
+ <property name="label">gtk-ok</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkNotebook" id="notebook1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="border_width">5</property>
+ <child>
+ <object class="GtkGrid" id="input-grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">12</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkLabel" id="var1-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Input range:</property>
+ <property name="use_underline">True</property>
+ <property name="justify">right</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Grouped by:</property>
+ <property name="justify">center</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="grouped_by_col">
+ <property name="label" translatable="yes" context="groupby" comments="Group by Columns">_Columns</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="grouped_by_row">
+ <property name="label" translatable="yes" context="groupby" comments="Group by Rows">_Rows</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">grouped_by_col</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="grouped_by_area">
+ <property name="label" translatable="yes">_Areas</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">grouped_by_col</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="labels_button">
+ <property name="label" translatable="yes">_Labels</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Input</property>
+ </object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="test-grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">12</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="mean-entry-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Predicted Mean:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Alpha:</property>
+ <property name="use_underline">True</property>
+ <property name="justify">right</property>
+ <property name="mnemonic_widget">alpha-entry</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="alpha-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ <property name="invisible_char_set">True</property>
+ <property name="adjustment">adjustment1</property>
+ <property name="climb_rate">0.01</property>
+ <property name="digits">2</property>
+ <property name="numeric">True</property>
+ <property name="update_policy">if-valid</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="mean-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ <property name="text">0</property>
+ <property name="invisible_char_set">True</property>
+ <property name="caps_lock_warning">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Test</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="dao">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Output</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="warnings">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_markup">True</property>
+ <property name="wrap">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">helpbutton</action-widget>
+ <action-widget response="0">cancelbutton</action-widget>
+ <action-widget response="0">okbutton</action-widget>
+ </action-widgets>
+ </object>
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="upper">1</property>
+ <property name="value">0.050000000000000003</property>
+ <property name="step_increment">0.01</property>
+ <property name="page_increment">10</property>
+ </object>
+</interface>
diff --git a/src/tools/ChangeLog b/src/tools/ChangeLog
index 978ab27..20f4911 100644
--- a/src/tools/ChangeLog
+++ b/src/tools/ChangeLog
@@ -1,3 +1,9 @@
+2012-06-11 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * analysis-one-mean-test.c: new
+ * analysis-one-mean-test.h: new
+ * Makefile.am: add the above
+
2012-06-03 Andreas J. Guelzow <aguelzow pyrshep ca>
* analysis-wilcoxon-mann-whitney.c
diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am
index 6262a55..70e25fe 100644
--- a/src/tools/Makefile.am
+++ b/src/tools/Makefile.am
@@ -31,6 +31,8 @@ libtools_la_SOURCES = \
analysis-kaplan-meier.h \
analysis-normality.c \
analysis-normality.h \
+ analysis-one-mean-test.c \
+ analysis-one-mean-test.h \
analysis-principal-components.c \
analysis-principal-components.h \
analysis-sign-test.c \
diff --git a/src/tools/analysis-one-mean-test.c b/src/tools/analysis-one-mean-test.c
new file mode 100644
index 0000000..5e6cc0f
--- /dev/null
+++ b/src/tools/analysis-one-mean-test.c
@@ -0,0 +1,178 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * analysis-one-mean-test.c:
+ *
+ * Author:
+ * Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ * (C) Copyright 2009 by Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gnumeric-config.h>
+#include <glib/gi18n-lib.h>
+#include "gnumeric.h"
+#include "analysis-one-mean-test.h"
+#include "analysis-tools.h"
+#include "value.h"
+#include "ranges.h"
+#include "expr.h"
+#include "func.h"
+#include "numbers.h"
+
+static gboolean
+analysis_tool_one_mean_test_engine_run (data_analysis_output_t *dao,
+ analysis_tools_data_one_mean_test_t *info)
+{
+ guint col;
+ GSList *data = info->base.input;
+ gboolean first = TRUE;
+
+ GnmFunc *fd_mean;
+ GnmFunc *fd_var;
+ GnmFunc *fd_sqrt;
+ GnmFunc *fd_abs;
+ GnmFunc *fd_tdist;
+ GnmFunc *fd_iferror;
+ GnmFunc *fd_count;
+
+ fd_count = gnm_func_lookup_or_add_placeholder ("COUNT", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_count);
+ fd_mean = gnm_func_lookup_or_add_placeholder ("AVERAGE", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_mean);
+ fd_var = gnm_func_lookup_or_add_placeholder ("VAR", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_var);
+ fd_sqrt = gnm_func_lookup_or_add_placeholder ("SQRT", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_sqrt);
+ fd_abs = gnm_func_lookup_or_add_placeholder ("ABS", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_abs);
+ fd_tdist = gnm_func_lookup_or_add_placeholder ("TDIST", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_tdist);
+ fd_iferror = gnm_func_lookup_or_add_placeholder ("IFERROR", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_iferror);
+
+ dao_set_italic (dao, 0, 0, 0, 9);
+ set_cell_text_col (dao, 0, 0, _("/Student-t Test"
+ "/N"
+ "/Observed Mean"
+ "/Hypothesized Mean"
+ "/Observed Variance"
+ "/Test Statistic"
+ "/df"
+ "/\xce\xb1"
+ "/P(T\xe2\x89\xa4t) one-tailed"
+ "/P(T\xe2\x89\xa4t) two-tailed"));
+
+ for (col = 1; data != NULL; data = data->next, col++) {
+ GnmValue *val_org = value_dup (data->data);
+ GnmExpr const *expr;
+ GnmExpr const *expr_org;
+ GnmExpr const *expr_range_clean;
+ GnmExpr const *expr_stddev;
+ GnmExpr const *expr_abs;
+
+ /* Note that analysis_tools_write_label may modify val_org */
+ dao_set_italic (dao, col, 0, col, 0);
+ analysis_tools_write_label (val_org, dao, &info->base, col, 0, col);
+ expr_org = gnm_expr_new_constant (val_org);
+ expr_range_clean = gnm_expr_new_funcall2
+ (fd_iferror, gnm_expr_copy (expr_org), gnm_expr_new_constant (value_new_string("")));
+
+ if (first) {
+ dao_set_cell_float (dao, col, 3, info->mean);
+ dao_set_cell_float (dao, col, 7, info->alpha);
+ first = FALSE;
+ } else {
+ dao_set_cell_expr (dao, col, 3, make_cellref (-1,0));
+ dao_set_cell_expr (dao, col, 7, make_cellref (-1,0));
+ }
+
+ expr = gnm_expr_new_funcall1 (fd_count, expr_org);
+ dao_set_cell_expr (dao, col, 1, expr);
+
+ expr = gnm_expr_new_funcall1 (fd_mean, gnm_expr_copy (expr_range_clean));
+ dao_set_cell_array_expr (dao, col, 2, expr);
+
+ expr = gnm_expr_new_funcall1 (fd_var, expr_range_clean);
+ dao_set_cell_array_expr (dao, col, 4, expr);
+
+ dao_set_cell_expr (dao, col, 6, gnm_expr_new_binary
+ (make_cellref (0,-5), GNM_EXPR_OP_SUB, gnm_expr_new_constant (value_new_int (1))));
+
+ expr_stddev = gnm_expr_new_funcall1
+ (fd_sqrt, gnm_expr_new_binary (make_cellref (0,-1), GNM_EXPR_OP_DIV, make_cellref (0,-4)));
+ expr = gnm_expr_new_binary
+ (gnm_expr_new_binary (make_cellref (0,-3), GNM_EXPR_OP_SUB, make_cellref (0,-2)),
+ GNM_EXPR_OP_DIV,
+ expr_stddev);
+ dao_set_cell_array_expr (dao, col, 5, expr);
+
+ expr_abs = gnm_expr_new_funcall1 (fd_abs, make_cellref (0,-3));
+ expr = gnm_expr_new_funcall3 (fd_tdist, expr_abs, make_cellref (0,-2),
+ gnm_expr_new_constant (value_new_int (1)));
+ dao_set_cell_expr (dao, col, 8, expr);
+
+ expr_abs = gnm_expr_new_funcall1 (fd_abs, make_cellref (0,-4));
+ expr = gnm_expr_new_funcall3 (fd_tdist, expr_abs, make_cellref (0,-3),
+ gnm_expr_new_constant (value_new_int (2)));
+ dao_set_cell_expr (dao, col, 9, expr);
+ }
+ gnm_func_unref (fd_count);
+ gnm_func_unref (fd_mean);
+ gnm_func_unref (fd_var);
+ gnm_func_unref (fd_abs);
+ gnm_func_unref (fd_sqrt);
+ gnm_func_unref (fd_tdist);
+ gnm_func_unref (fd_iferror);
+
+ dao_redraw_respan (dao);
+
+ return FALSE;
+}
+
+
+gboolean
+analysis_tool_one_mean_test_engine (G_GNUC_UNUSED GOCmdContext *gcc, data_analysis_output_t *dao, gpointer specs,
+ analysis_tool_engine_t selector, gpointer result)
+{
+ analysis_tools_data_one_mean_test_t *info = specs;
+
+ switch (selector) {
+ case TOOL_ENGINE_UPDATE_DESCRIPTOR:
+ return (dao_command_descriptor
+ (dao, _("Student-t Test (%s)"), result)
+ == NULL);
+ case TOOL_ENGINE_UPDATE_DAO:
+ prepare_input_range (&info->base.input, info->base.group_by);
+ dao_adjust (dao, 1 + g_slist_length (info->base.input), 10);
+ return FALSE;
+ case TOOL_ENGINE_CLEAN_UP:
+ return analysis_tool_generic_clean (specs);
+ case TOOL_ENGINE_LAST_VALIDITY_CHECK:
+ return FALSE;
+ case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
+ dao_prepare_output (NULL, dao, _("Student-t Test"));
+ return FALSE;
+ case TOOL_ENGINE_FORMAT_OUTPUT_RANGE:
+ return dao_format_output (dao, _("Student-t Test"));
+ case TOOL_ENGINE_PERFORM_CALC:
+ default:
+ return analysis_tool_one_mean_test_engine_run (dao, specs);
+ }
+ return TRUE;
+}
+
diff --git a/src/tools/analysis-one-mean-test.h b/src/tools/analysis-one-mean-test.h
new file mode 100644
index 0000000..dfaafa6
--- /dev/null
+++ b/src/tools/analysis-one-mean-test.h
@@ -0,0 +1,49 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * analysis-one-mean-test.h:
+ *
+ * Author:
+ * Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ * (C) Copyright 2012 by Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#ifndef ANALYSIS_ONE_MEAN_TEST_H
+#define ANALYSIS_ONE_MEAN_TEST_H
+
+#include "gnumeric.h"
+#include "numbers.h"
+#include "dao.h"
+#include "tools.h"
+#include "analysis-tools.h"
+#include "sheet.h"
+
+typedef struct {
+ analysis_tools_data_generic_t base;
+ gnm_float mean;
+ gnm_float alpha;
+} analysis_tools_data_one_mean_test_t;
+
+gboolean analysis_tool_one_mean_test_engine (GOCmdContext *gcc,
+ data_analysis_output_t *dao,
+ gpointer specs,
+ analysis_tool_engine_t selector,
+ gpointer result);
+
+#endif
diff --git a/src/wbc-gtk-actions.c b/src/wbc-gtk-actions.c
index 177dbaf..ab2e93e 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -959,6 +959,7 @@ static GNM_ACTION_DEF (cb_tools_frequency) { dialog_frequency_tool (wbcg, wbcg_c
static GNM_ACTION_DEF (cb_tools_histogram) { dialog_histogram_tool (wbcg, wbcg_cur_sheet (wbcg)); }
static GNM_ACTION_DEF (cb_tools_kaplan_meier) { dialog_kaplan_meier_tool (wbcg, wbcg_cur_sheet (wbcg)); }
static GNM_ACTION_DEF (cb_tools_normality_tests){ dialog_normality_tool (wbcg, wbcg_cur_sheet (wbcg)); }
+static GNM_ACTION_DEF (cb_tools_one_mean_test) { dialog_one_mean_test_tool (wbcg, wbcg_cur_sheet (wbcg)); }
static GNM_ACTION_DEF (cb_tools_principal_components) { dialog_principal_components_tool (wbcg, wbcg_cur_sheet (wbcg)); }
static GNM_ACTION_DEF (cb_tools_ranking) { dialog_ranking_tool (wbcg, wbcg_cur_sheet (wbcg)); }
static GNM_ACTION_DEF (cb_tools_regression) { dialog_regression_tool (wbcg, wbcg_cur_sheet (wbcg)); }
@@ -2516,6 +2517,9 @@ static GtkActionEntry const actions[] = {
{ "ToolsNormalityTests", NULL, N_("_Normality Tests..."),
NULL, N_("Testing a sample for normality"),
G_CALLBACK (cb_tools_normality_tests) },
+ { "ToolsOneMeanTest", NULL, N_("_Student-T Test..."),
+ NULL, N_("Testing the value of a mean"),
+ G_CALLBACK (cb_tools_one_mean_test) },
/* Statistics -> OneSample -> OneMedian*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]