[gnumeric] Add Wilcoxon-Mann-Whitney test tool.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Add Wilcoxon-Mann-Whitney test tool.
- Date: Mon, 24 May 2010 22:54:57 +0000 (UTC)
commit 46639199daff90a8c66d4989d60e4eee31ff9fc6
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Mon May 24 16:51:06 2010 -0600
Add Wilcoxon-Mann-Whitney test tool.
2010-05-24 Andreas J. Guelzow <aguelzow pyrshep ca>
* analysis-wilcoxon-mann-whitney.c: new
* analysis-wilcoxon-mann-whitney.h: new
* analysis-tools.h (analysis_tools_write_a_label): new
(analysis_tools_remove_label): new
* analysis-tools.c (analysis_tools_write_a_label): make public
(analysis_tools_remove_label): ditto
2010-05-24 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-analysis-tool-wilcoxon-mann-whitney.c: new
* wilcoxon-mann-whitney.glade: new
* Makefile.am: added wilcoxon-mann-whitney.glade
and dialog-analysis-tool-wilcoxon-mann-whitney.c
* dialogs.h (dialog_wilcoxon_m_w_tool): new
* help.h (GNUMERIC_HELP_LINK_WILCOXON_MANN_WHITNEY): new
2010-05-24 Andreas J. Guelzow <aguelzow pyrshep ca>
* component/Gnumeric-embed.xml.in: added Wilcoxon menu item.
* src/GNOME_Gnumeric-gtk.xml.in: ditto
* src/HILDON_Gnumeric-gtk.xml.in: ditto
* src/wbc-gtk-actions.c (MenuToolTwoMedians): new submenu
(cb_tools_wilcoxon_mann_whitney): new
(ToolsTwoMedianWilcoxonMannWhitney): new
2010-05-24 Andreas J. Guelzow <aguelzow pyrshep ca>
* POTFILES.in: added wilcoxon-mann-whitney.glade,
dialog-analysis-tool-wilcoxon-mann-whitney.c and
analysis-wilcoxon-mann-whitney.c
2010-05-24 Andreas J. Guelzow <aguelzow pyrshep ca>
* POTFILES.in: added
dialog-analysis-tool-wilcoxon-mann-whitney.c and
analysis-wilcoxon-mann-whitney.c
* POTFILES.skip: added wilcoxon-mann-whitney.glade
ChangeLog | 9 +
NEWS | 3 +
component/Gnumeric-embed.xml.in | 5 +-
po-functions/ChangeLog | 7 +
po-functions/POTFILES.in | 2 +
po-functions/POTFILES.skip | 1 +
po/ChangeLog | 6 +
po/POTFILES.in | 3 +
src/GNOME_Gnumeric-gtk.xml.in | 5 +-
src/HILDON_Gnumeric-gtk.xml.in | 5 +-
src/dialogs/ChangeLog | 9 +
src/dialogs/Makefile.am | 2 +
.../dialog-analysis-tool-wilcoxon-mann-whitney.c | 213 ++++++++++++
src/dialogs/dialogs.h | 1 +
src/dialogs/help.h | 3 +
src/dialogs/wilcoxon-mann-whitney.glade | 323 +++++++++++++++++
src/tools/ChangeLog | 9 +
src/tools/Makefile.am | 2 +
src/tools/analysis-tools.c | 4 +-
src/tools/analysis-tools.h | 22 +-
src/tools/analysis-wilcoxon-mann-whitney.c | 363 ++++++++++++++++++++
src/tools/analysis-wilcoxon-mann-whitney.h | 42 +++
src/wbc-gtk-actions.c | 16 +-
23 files changed, 1041 insertions(+), 14 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7985443..2e737b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-05-24 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * component/Gnumeric-embed.xml.in: added Wilcoxon menu item.
+ * src/GNOME_Gnumeric-gtk.xml.in: ditto
+ * src/HILDON_Gnumeric-gtk.xml.in: ditto
+ * src/wbc-gtk-actions.c (MenuToolTwoMedians): new submenu
+ (cb_tools_wilcoxon_mann_whitney): new
+ (ToolsTwoMedianWilcoxonMannWhitney): new
+
2010-05-24 Morten Welinder <terra gnome org>
* src/ssconvert.c (ssconvert_options): Hide the --solve flag as
diff --git a/NEWS b/NEWS
index 6099ee8..8a0a308 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
Gnumeric 1.10.5
+Andreas:
+ * Add Wilcoxon-Mann-Whitney test tool.
+
Morten:
* Fix stf crash. [#619283]
* Persist solver model type.
diff --git a/component/Gnumeric-embed.xml.in b/component/Gnumeric-embed.xml.in
index 31c20af..f9d5ab5 100644
--- a/component/Gnumeric-embed.xml.in
+++ b/component/Gnumeric-embed.xml.in
@@ -188,7 +188,10 @@
<menuitem action="ToolsRegression"/>
<menuitem action="ToolsSampling"/>
<menuitem action="ToolsOneMedianSignTest"/>
- <menuitem action="ToolsTwoMedianSignTest"/>
+ <menu name="ToolTwoMedians" action="MenuToolTwoMedians">
+ <menuitem action="ToolsTwoMedianSignTest"/>
+ <menuitem action="ToolsTwoMedianWilcoxonMannWhitney"/>
+ </menu>
<menu name="ToolTTest" action="MenuToolTTest">
<menuitem action="ToolTTestPaired"/>
<menuitem action="ToolTTestEqualVar"/>
diff --git a/po-functions/ChangeLog b/po-functions/ChangeLog
index 9244036..57e86c1 100644
--- a/po-functions/ChangeLog
+++ b/po-functions/ChangeLog
@@ -1,3 +1,10 @@
+2010-05-24 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * POTFILES.in: added
+ dialog-analysis-tool-wilcoxon-mann-whitney.c and
+ analysis-wilcoxon-mann-whitney.c
+ * POTFILES.skip: added wilcoxon-mann-whitney.glade
+
2010-05-20 Morten Welinder <terra gnome org>
* Release 1.10.4
diff --git a/po-functions/POTFILES.in b/po-functions/POTFILES.in
index 492c861..46c9cb2 100644
--- a/po-functions/POTFILES.in
+++ b/po-functions/POTFILES.in
@@ -81,6 +81,7 @@ src/dialogs/dialog-analysis-tool-kaplan-meier.c
src/dialogs/dialog-analysis-tool-normality.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
src/dialogs/dialog-analysis-tools.c
src/dialogs/dialog-autofilter.c
src/dialogs/dialog-autoformat.c
@@ -205,6 +206,7 @@ src/tools/analysis-normality.c
src/tools/analysis-principal-components.c
src/tools/analysis-sign-test.c
src/tools/analysis-tools.c
+src/tools/analysis-wilcoxon-mann-whitney.c
src/tools/dao.c
src/tools/data-shuffling.c
src/tools/fill-series.c
diff --git a/po-functions/POTFILES.skip b/po-functions/POTFILES.skip
index 9ab127f..c2a5f8d 100644
--- a/po-functions/POTFILES.skip
+++ b/po-functions/POTFILES.skip
@@ -145,6 +145,7 @@ src/dialogs/solver.glade
src/dialogs/tabulate.glade
src/dialogs/variance-tests.glade
src/dialogs/view.glade
+src/dialogs/wilcoxon-mann-whitney.glade
src/dialogs/workbook-attr.glade
templates/autoformat/3D.category.in
templates/autoformat/Classical.category.in
diff --git a/po/ChangeLog b/po/ChangeLog
index 6d70169..f4efa16 100644
--- a/po/ChangeLog
+++ b/po/ChangeLog
@@ -1,3 +1,9 @@
+2010-05-24 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * POTFILES.in: added wilcoxon-mann-whitney.glade,
+ dialog-analysis-tool-wilcoxon-mann-whitney.c and
+ analysis-wilcoxon-mann-whitney.c
+
2010-05-20 Morten Welinder <terra gnome org>
* Release 1.10.4
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 24006c5..ba075ba 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -163,6 +163,7 @@ src/dialogs/dialog-analysis-tool-kaplan-meier.c
src/dialogs/dialog-analysis-tool-normality.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
src/dialogs/dialog-analysis-tools.c
src/dialogs/dialog-autofilter.c
src/dialogs/dialog-autoformat.c
@@ -274,6 +275,7 @@ src/dialogs/solver.glade
src/dialogs/tabulate.glade
src/dialogs/variance-tests.glade
src/dialogs/view.glade
+src/dialogs/wilcoxon-mann-whitney.glade
src/dialogs/workbook-attr.glade
src/expr-name.c
src/expr.c
@@ -343,6 +345,7 @@ src/tools/analysis-normality.c
src/tools/analysis-principal-components.c
src/tools/analysis-sign-test.c
src/tools/analysis-tools.c
+src/tools/analysis-wilcoxon-mann-whitney.c
src/tools/dao.c
src/tools/data-shuffling.c
src/tools/fill-series.c
diff --git a/src/GNOME_Gnumeric-gtk.xml.in b/src/GNOME_Gnumeric-gtk.xml.in
index 73e85f5..1f36919 100644
--- a/src/GNOME_Gnumeric-gtk.xml.in
+++ b/src/GNOME_Gnumeric-gtk.xml.in
@@ -189,7 +189,10 @@
<menuitem action="ToolsRegression"/>
<menuitem action="ToolsSampling"/>
<menuitem action="ToolsOneMedianSignTest"/>
- <menuitem action="ToolsTwoMedianSignTest"/>
+ <menu name="ToolTwoMedians" action="MenuToolTwoMedians">
+ <menuitem action="ToolsTwoMedianSignTest"/>
+ <menuitem action="ToolsTwoMedianWilcoxonMannWhitney"/>
+ </menu>
<menu name="ToolTTest" action="MenuToolTTest">
<menuitem action="ToolTTestPaired"/>
<menuitem action="ToolTTestEqualVar"/>
diff --git a/src/HILDON_Gnumeric-gtk.xml.in b/src/HILDON_Gnumeric-gtk.xml.in
index f2b4980..3056470 100644
--- a/src/HILDON_Gnumeric-gtk.xml.in
+++ b/src/HILDON_Gnumeric-gtk.xml.in
@@ -197,7 +197,10 @@
<menuitem action="ToolsRegression"/>
<menuitem action="ToolsSampling"/>
<menuitem action="ToolsOneMedianSignTest"/>
- <menuitem action="ToolsTwoMedianSignTest"/>
+ <menu name="ToolTwoMedians" action="MenuToolTwoMedians">
+ <menuitem action="ToolsTwoMedianSignTest"/>
+ <menuitem action="ToolsTwoMedianWilcoxonMannWhitney"/>
+ </menu>
<menu name="ToolTTest" action="MenuToolTTest">
<menuitem action="ToolTTestPaired"/>
<menuitem action="ToolTTestEqualVar"/>
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index bf3bdfa..f64ff8e 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,12 @@
+2010-05-24 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * dialog-analysis-tool-wilcoxon-mann-whitney.c: new
+ * wilcoxon-mann-whitney.glade: new
+ * Makefile.am: added wilcoxon-mann-whitney.glade
+ and dialog-analysis-tool-wilcoxon-mann-whitney.c
+ * dialogs.h (dialog_wilcoxon_m_w_tool): new
+ * help.h (GNUMERIC_HELP_LINK_WILCOXON_MANN_WHITNEY): new
+
2010-05-20 Morten Welinder <terra gnome org>
* Release 1.10.4
diff --git a/src/dialogs/Makefile.am b/src/dialogs/Makefile.am
index ec9de5d..ddae9dc 100644
--- a/src/dialogs/Makefile.am
+++ b/src/dialogs/Makefile.am
@@ -32,6 +32,7 @@ base_files = \
dialog-analysis-tool-normality.c \
dialog-analysis-tool-principal-components.c \
dialog-analysis-tool-sign-test.c \
+ dialog-analysis-tool-wilcoxon-mann-whitney.c \
dialog-autofilter.c \
dialog-autoformat.c \
dialog-autosave.c \
@@ -170,6 +171,7 @@ glade_DATA = \
tabulate.glade \
variance-tests.glade \
view.glade \
+ wilcoxon-mann-whitney.glade \
workbook-attr.glade \
print.glade
diff --git a/src/dialogs/dialog-analysis-tool-wilcoxon-mann-whitney.c b/src/dialogs/dialog-analysis-tool-wilcoxon-mann-whitney.c
new file mode 100644
index 0000000..5d5a5c3
--- /dev/null
+++ b/src/dialogs/dialog-analysis-tool-wilcoxon-mann-whitney.c
@@ -0,0 +1,213 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * dialog-analysis-tool-wilcoxon-mann-whitney.c:
+ *
+ * Authors:
+ * Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ * (C) Copyright 2010 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-wilcoxon-mann-whitney.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 <glade/glade.h>
+#include <string.h>
+#include <gtk/gtk.h>
+
+#define WILCOXON_MANN_WHITNEY_KEY "analysistools-principal-components-dialog"
+
+static char const * const grouped_by_group[] = {
+ "grouped_by_row",
+ "grouped_by_col",
+ "grouped_by_area",
+ NULL
+};
+
+static void
+wilcoxon_mann_whitney_tool_update_sensitivity_cb (G_GNUC_UNUSED GtkWidget *dummy,
+ GenericToolState *state)
+{
+ GnmValue *input_range;
+
+ /* Checking Input Range */
+ input_range = gnm_expr_entry_parse_as_value (
+ GNM_EXPR_ENTRY (state->input_entry), state->sheet);
+ if (input_range == NULL) {
+ gtk_label_set_text (GTK_LABEL (state->warning),
+ _("The input range is invalid."));
+ gtk_widget_set_sensitive (state->ok_button, FALSE);
+ return;
+ } else {
+ GnmRangeRef const *rr = value_get_rangeref (input_range);
+ guint len = 0;
+ GnmRange r;
+
+ if (rr != NULL) {
+ group_by_t group_by
+ = gnumeric_glade_group_value
+ (state->gui, grouped_by_group);
+ range_init_rangeref (&r, rr);
+ len = (group_by == GROUPED_BY_ROW)
+ ? range_height (&r) : range_width (&r);
+ }
+
+ value_release (input_range);
+ if (len != 2) {
+ gtk_label_set_text (GTK_LABEL (state->warning),
+ _("The input range should consists of 2 groups."));
+ gtk_widget_set_sensitive (state->ok_button, FALSE);
+ return;
+ }
+ }
+
+ /* Checking Output Page */
+ if (!gnm_dao_is_ready (GNM_DAO (state->gdao))) {
+ gtk_label_set_text (GTK_LABEL (state->warning),
+ _("The output specification "
+ "is invalid."));
+ gtk_widget_set_sensitive (state->ok_button, FALSE);
+ return;
+ }
+
+ gtk_label_set_text (GTK_LABEL (state->warning), "");
+ gtk_widget_set_sensitive (state->ok_button, TRUE);
+
+ return;
+}
+
+/**
+ * wilcoxon_mann_whitney_tool_ok_clicked_cb:
+ * @button:
+ * @state:
+ *
+ **/
+static void
+wilcoxon_mann_whitney_tool_ok_clicked_cb (G_GNUC_UNUSED GtkWidget *button,
+ GenericToolState *state)
+{
+ data_analysis_output_t *dao;
+ analysis_tools_data_generic_t *data;
+
+ char *text;
+ GtkWidget *w;
+
+ if (state->warning_dialog != NULL)
+ gtk_widget_destroy (state->warning_dialog);
+
+ data = g_new0 (analysis_tools_data_generic_t, 1);
+ dao = parse_output (state, NULL);
+
+ data->input = gnm_expr_entry_parse_as_list (
+ GNM_EXPR_ENTRY (state->input_entry), state->sheet);
+ data->group_by = gnumeric_glade_group_value (state->gui, grouped_by_group);
+
+ w = glade_xml_get_widget (state->gui, "labels_button");
+ data->labels = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
+
+ if (cmd_analysis_tool (WORKBOOK_CONTROL (state->wbcg), state->sheet,
+ dao, data, analysis_tool_wilcoxon_mann_whitney_engine)) {
+ text = g_strdup_printf (
+ _("An unexpected error has occurred: %d."), data->err);
+ error_in_entry ((GenericToolState *) state,
+ GTK_WIDGET (state->input_entry), text);
+ g_free (text);
+ range_list_destroy (data->input);
+ g_free (dao);
+ g_free (data);
+ } else
+ gtk_widget_destroy (state->dialog);
+ return;
+}
+
+
+
+/**
+ * dialog_wilcoxon_mann_whitney_tool:
+ * @wbcg:
+ * @sheet:
+ *
+ * Show the dialog (guru).
+ *
+ **/
+int
+dialog_wilcoxon_m_w_tool (WBCGtk *wbcg, Sheet *sheet)
+{
+ GenericToolState *state;
+ char const * plugins[] = { "Gnumeric_fnstat",
+ "Gnumeric_fnmath",
+ "Gnumeric_fnlookup",
+ NULL};
+
+ 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, WILCOXON_MANN_WHITNEY_KEY))
+ return 0;
+
+ state = g_new0 (GenericToolState, 1);
+
+ if (dialog_tool_init (state, wbcg, sheet,
+ GNUMERIC_HELP_LINK_WILCOXON_MANN_WHITNEY,
+ "wilcoxon-mann-whitney.glade", "WilcoxonMannWhitney",
+ _("Could not create the Wilcoxon-Mann-Whitney Analysis Tool dialog."),
+ WILCOXON_MANN_WHITNEY_KEY,
+ G_CALLBACK (wilcoxon_mann_whitney_tool_ok_clicked_cb), NULL,
+ G_CALLBACK (wilcoxon_mann_whitney_tool_update_sensitivity_cb),
+ GNM_EE_SINGLE_RANGE))
+ return 0;
+
+ g_signal_connect_after
+ (G_OBJECT (glade_xml_get_widget
+ (state->gui,
+ "grouped_by_row")), "toggled",
+ G_CALLBACK (wilcoxon_mann_whitney_tool_update_sensitivity_cb),
+ state);
+
+ gnm_dao_set_put (GNM_DAO (state->gdao), TRUE, TRUE);
+ wilcoxon_mann_whitney_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 73c22fd..1d1494f 100644
--- a/src/dialogs/dialogs.h
+++ b/src/dialogs/dialogs.h
@@ -94,6 +94,7 @@ int dialog_kaplan_meier_tool (WBCGtk *wbcg, Sheet *sheet);
int dialog_normality_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);
typedef enum {
SIGNTEST_1 = 1,
diff --git a/src/dialogs/help.h b/src/dialogs/help.h
index e26f7bd..f51b17d 100644
--- a/src/dialogs/help.h
+++ b/src/dialogs/help.h
@@ -165,6 +165,9 @@
/* dialog-analysis-tool-sign-test.c */
#define GNUMERIC_HELP_LINK_SIGN_TEST "sign-test-tool"
+/* dialog-analysis-tool-wilcoxon-mann-whitney.c */
+#define GNUMERIC_HELP_LINK_WILCOXON_MANN_WHITNEY "wilcoxon-mann-whitney-tool"
+
/* dialog-consolidate.c */
#define GNUMERIC_HELP_LINK_CONSOLIDATE ""
diff --git a/src/dialogs/wilcoxon-mann-whitney.glade b/src/dialogs/wilcoxon-mann-whitney.glade
new file mode 100755
index 0000000..9003c94
--- /dev/null
+++ b/src/dialogs/wilcoxon-mann-whitney.glade
@@ -0,0 +1,323 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+
+<widget class="GtkDialog" id="WilcoxonMannWhitney">
+ <property name="title" translatable="yes">Wilcoxon-Mann-Whitney Test</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="has_separator">False</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">8</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="hbuttonbox1">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="helpbutton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-help</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="response_id">0</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="cancelbutton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="response_id">0</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="okbutton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-ok</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="response_id">0</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkNotebook" id="notebook1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="show_tabs">True</property>
+ <property name="show_border">True</property>
+ <property name="tab_pos">GTK_POS_TOP</property>
+ <property name="scrollable">False</property>
+ <property name="enable_popup">False</property>
+
+ <child>
+ <widget class="GtkTable" id="input-table">
+ <property name="border_width">12</property>
+ <property name="visible">True</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="homogeneous">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+
+ <child>
+ <widget class="GtkLabel" id="var1-label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Input range:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_RIGHT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">5</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Grouped by:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_CENTER</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">5</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="labels_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Labels</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">True</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkRadioButton" id="grouped_by_col">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Columns</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="active">True</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkRadioButton" id="grouped_by_row">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Rows</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">grouped_by_col</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkRadioButton" id="grouped_by_area">
+ <property name="visible">False</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Areas</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">grouped_by_col</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options">fill</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="tab_expand">False</property>
+ <property name="tab_fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Input</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="dao">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="tab_expand">False</property>
+ <property name="tab_fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Output</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="warnings">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">True</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+</glade-interface>
diff --git a/src/tools/ChangeLog b/src/tools/ChangeLog
index 0a0935b..4b86018 100644
--- a/src/tools/ChangeLog
+++ b/src/tools/ChangeLog
@@ -1,3 +1,12 @@
+2010-05-24 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * analysis-wilcoxon-mann-whitney.c: new
+ * analysis-wilcoxon-mann-whitney.h: new
+ * analysis-tools.h (analysis_tools_write_a_label): new
+ (analysis_tools_remove_label): new
+ * analysis-tools.c (analysis_tools_write_a_label): make public
+ (analysis_tools_remove_label): ditto
+
2010-05-22 Morten Welinder <terra gnome org>
* gnm-solver.c (gnm_solver_get_current_values): New function.
diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am
index 6e3de5f..2bbc09b 100644
--- a/src/tools/Makefile.am
+++ b/src/tools/Makefile.am
@@ -37,6 +37,8 @@ libtools_la_SOURCES = \
analysis-sign-test.h \
analysis-tools.c \
analysis-tools.h \
+ analysis-wilcoxon-mann-whitney.c \
+ analysis-wilcoxon-mann-whitney.h \
random-generator.c \
random-generator.h \
random-generator-cor.c \
diff --git a/src/tools/analysis-tools.c b/src/tools/analysis-tools.c
index cba3699..0c22a5d 100644
--- a/src/tools/analysis-tools.c
+++ b/src/tools/analysis-tools.c
@@ -132,7 +132,7 @@ cb_adjust_areas (gpointer data, G_GNUC_UNUSED gpointer user_data)
*
*/
-static void
+void
analysis_tools_remove_label (GnmValue *val,
gboolean labels, group_by_t group_by)
{
@@ -211,7 +211,7 @@ analysis_tools_write_label (GnmValue *val, data_analysis_output_t *dao,
*
*/
-static void
+void
analysis_tools_write_a_label (GnmValue *val, data_analysis_output_t *dao,
gboolean labels, group_by_t group_by,
int x, int y)
diff --git a/src/tools/analysis-tools.h b/src/tools/analysis-tools.h
index 0964fc5..b21af92 100644
--- a/src/tools/analysis-tools.h
+++ b/src/tools/analysis-tools.h
@@ -224,11 +224,23 @@ gboolean analysis_tool_generic_clean (gpointer specs);
gboolean analysis_tool_generic_b_clean (gpointer specs);
int analysis_tool_calc_length (analysis_tools_data_generic_t *info);
-void analysis_tools_write_label (GnmValue *val, data_analysis_output_t *dao,
- analysis_tools_data_generic_t *info,
- int x, int y, int i);
-void analysis_tools_write_label_ftest (GnmValue *val, data_analysis_output_t *dao,
- int x, int y, gboolean labels, int i);
+
+void analysis_tools_write_label (GnmValue *val, /* depreceated */
+ data_analysis_output_t *dao,
+ analysis_tools_data_generic_t *info,
+ int x, int y, int i);
+void analysis_tools_write_label_ftest (GnmValue *val, /* depreceated */
+ data_analysis_output_t *dao,
+ int x, int y,
+ gboolean labels, int i);
+void analysis_tools_write_a_label (GnmValue *val,
+ data_analysis_output_t *dao,
+ gboolean labels,
+ group_by_t group_by,
+ int x, int y);
+void analysis_tools_remove_label (GnmValue *val,
+ gboolean labels,
+ group_by_t group_by);
gboolean analysis_tool_table (data_analysis_output_t *dao,
analysis_tools_data_generic_t *info,
diff --git a/src/tools/analysis-wilcoxon-mann-whitney.c b/src/tools/analysis-wilcoxon-mann-whitney.c
new file mode 100644
index 0000000..088604e
--- /dev/null
+++ b/src/tools/analysis-wilcoxon-mann-whitney.c
@@ -0,0 +1,363 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * analysis-wilcoxon-mann-whitney.c:
+ *
+ * Author:
+ * Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ * (C) Copyright 2010 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-wilcoxon-mann-whitney.h"
+#include "analysis-tools.h"
+#include "value.h"
+#include "ranges.h"
+#include "expr.h"
+#include "func.h"
+#include "numbers.h"
+
+static gboolean
+analysis_tool_wilcoxon_mann_whitney_engine_run (data_analysis_output_t *dao,
+ analysis_tools_data_generic_t *info)
+{
+ GnmFunc *fd_count;
+ GnmFunc *fd_sum;
+ GnmFunc *fd_rows;
+ GnmFunc *fd_rank_avg;
+ GnmFunc *fd_rank;
+ GnmFunc *fd_min;
+ GnmFunc *fd_normdist;
+ GnmFunc *fd_sqrt;
+ GnmFunc *fd_if;
+ GnmFunc *fd_isblank;
+
+ GnmExpr const *expr_total;
+ GnmExpr const *expr_pop_1;
+ GnmExpr const *expr_pop_2;
+ GnmExpr const *expr_pop_1_adj;
+ GnmExpr const *expr_pop_2_adj;
+ GnmExpr const *expr_u;
+ GnmExpr const *expr_count_total;
+
+ GnmValue *total_pop = value_dup (info->input->data);
+
+ GSList *input = g_slist_append (NULL, value_dup (info->input->data));
+
+ prepare_input_range (&input, info->group_by);
+
+ fd_count = gnm_func_lookup_or_add_placeholder
+ ("COUNT", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_count);
+ fd_sum = gnm_func_lookup_or_add_placeholder
+ ("SUM", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_sum);
+ fd_rows = gnm_func_lookup_or_add_placeholder
+ ("ROWS", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_rows);
+ fd_rank_avg = gnm_func_lookup_or_add_placeholder
+ ("RANK.AVG", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_rank_avg);
+ fd_rank = gnm_func_lookup_or_add_placeholder
+ ("RANK", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_rank);
+ fd_min = gnm_func_lookup_or_add_placeholder
+ ("MIN", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_min);
+ fd_normdist = gnm_func_lookup_or_add_placeholder
+ ("NORMDIST", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_normdist);
+ fd_sqrt = gnm_func_lookup_or_add_placeholder
+ ("SQRT", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_sqrt);
+ fd_if = gnm_func_lookup_or_add_placeholder
+ ("IF", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_if);
+ fd_isblank = gnm_func_lookup_or_add_placeholder
+ ("ISBLANK", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_isblank);
+
+ dao_set_bold (dao, 0, 0, 0, 0);
+ dao_set_italic (dao, 0, 0, 0, 8);
+ dao_set_italic (dao, 0, 1, 3, 1);
+ dao_set_merge (dao, 0, 0, 3, 0);
+ dao_set_cell (dao, 0, 0, _("Wilcoxon-Mann-Whitney Test"));
+ set_cell_text_col (dao, 0, 2, _("/Rank-Sum:"
+ "/N:"
+ "/U:"
+ "/Ties:"
+ "/Statistics:"
+ "/U-Statistics:"
+ "/p-Value:"));
+ dao_set_cell (dao, 3, 1, _("Total"));
+
+ analysis_tools_remove_label (total_pop, info->labels, info->group_by);
+ expr_total = gnm_expr_new_constant (total_pop);
+ analysis_tools_write_a_label (input->data, dao,
+ info->labels, info->group_by,
+ 1, 1);
+ expr_pop_1 = gnm_expr_new_constant (input->data);
+ analysis_tools_write_a_label (input->next->data, dao,
+ info->labels, info->group_by,
+ 2, 1);
+ expr_pop_2 = gnm_expr_new_constant (input->next->data);
+
+ g_slist_free (input);
+
+ expr_pop_1_adj = gnm_expr_new_funcall3
+ (fd_if,
+ gnm_expr_new_funcall1
+ (fd_isblank,
+ gnm_expr_copy (expr_pop_1)),
+ gnm_expr_new_funcall1
+ (fd_min,
+ gnm_expr_copy (expr_total)),
+ gnm_expr_copy (expr_pop_1));
+ expr_pop_2_adj = gnm_expr_new_funcall3
+ (fd_if,
+ gnm_expr_new_funcall1
+ (fd_isblank,
+ gnm_expr_copy (expr_pop_2)),
+ gnm_expr_new_funcall1
+ (fd_min,
+ gnm_expr_copy (expr_total)),
+ gnm_expr_copy (expr_pop_2));
+
+ dao_set_cell_array_expr (dao, 1, 2,
+ gnm_expr_new_binary
+ (gnm_expr_new_funcall1
+ (fd_sum,
+ gnm_expr_new_funcall3
+ (fd_rank_avg,
+ expr_pop_1_adj,
+ gnm_expr_copy (expr_total),
+ gnm_expr_new_constant (value_new_int (1)))),
+ GNM_EXPR_OP_ADD,
+ gnm_expr_new_binary
+ (gnm_expr_new_funcall1
+ (fd_count,
+ gnm_expr_copy (expr_pop_1)),
+ GNM_EXPR_OP_SUB,
+ gnm_expr_new_funcall1
+ (fd_rows,
+ gnm_expr_copy (expr_pop_1)))));
+ dao_set_cell_array_expr (dao, 2, 2,
+ gnm_expr_new_binary
+ (gnm_expr_new_funcall1
+ (fd_sum,
+ gnm_expr_new_funcall3
+ (fd_rank_avg,
+ expr_pop_2_adj,
+ gnm_expr_copy (expr_total),
+ gnm_expr_new_constant (value_new_int (1)))),
+ GNM_EXPR_OP_ADD,
+ gnm_expr_new_binary
+ (gnm_expr_new_funcall1
+ (fd_count,
+ gnm_expr_copy (expr_pop_2)),
+ GNM_EXPR_OP_SUB,
+ gnm_expr_new_funcall1
+ (fd_rows,
+ gnm_expr_copy (expr_pop_2)))));
+
+ expr_count_total = gnm_expr_new_funcall1
+ (fd_count, gnm_expr_copy (expr_total));
+ dao_set_cell_expr (dao, 3, 2,
+ gnm_expr_new_binary
+ (gnm_expr_new_binary
+ (gnm_expr_copy (expr_count_total),
+ GNM_EXPR_OP_MULT,
+ gnm_expr_new_binary
+ (gnm_expr_copy (expr_count_total),
+ GNM_EXPR_OP_ADD,
+ gnm_expr_new_constant (value_new_int (1)))),
+ GNM_EXPR_OP_DIV,
+ gnm_expr_new_constant (value_new_int (2))));
+
+ dao_set_cell_expr (dao, 1, 3,
+ gnm_expr_new_funcall1
+ (fd_count,
+ expr_pop_1));
+ dao_set_cell_expr (dao, 2, 3,
+ gnm_expr_new_funcall1
+ (fd_count,
+ expr_pop_2));
+ dao_set_cell_expr (dao, 3, 3,
+ gnm_expr_new_funcall1
+ (fd_count,
+ gnm_expr_copy (expr_total)));
+
+ expr_u = gnm_expr_new_binary
+ (make_cellref (0,- 2), GNM_EXPR_OP_SUB,
+ gnm_expr_new_binary
+ (gnm_expr_new_binary
+ (make_cellref (0,- 1),
+ GNM_EXPR_OP_MULT,
+ gnm_expr_new_binary
+ (make_cellref (0,- 1),
+ GNM_EXPR_OP_ADD,
+ gnm_expr_new_constant (value_new_int (1)))),
+ GNM_EXPR_OP_DIV,
+ gnm_expr_new_constant (value_new_int (2))));
+
+ dao_set_cell_expr (dao, 1, 4, gnm_expr_copy (expr_u));
+ dao_set_cell_expr (dao, 2, 4, expr_u);
+ dao_set_cell_expr (dao, 3, 4,
+ gnm_expr_new_binary
+ (make_cellref (-2,-1),
+ GNM_EXPR_OP_MULT,
+ make_cellref (-1,-1)));
+
+ dao_set_cell_array_expr (dao, 1, 5,
+ gnm_expr_new_funcall1
+ (fd_sum,
+ gnm_expr_new_binary
+ (gnm_expr_new_funcall2
+ (fd_rank_avg,
+ gnm_expr_copy (expr_total),
+ gnm_expr_copy (expr_total)),
+ GNM_EXPR_OP_SUB,
+ gnm_expr_new_funcall2
+ (fd_rank,
+ gnm_expr_copy (expr_total),
+ gnm_expr_copy (expr_total)))));
+
+ if (dao_cell_is_visible (dao, 2, 4)) {
+ GnmExpr const *expr_prod;
+ GnmExpr const *expr_sqrt;
+ GnmExpr const *expr_normdist;
+
+ expr_prod = gnm_expr_new_binary
+ (make_cellref (0,-5),
+ GNM_EXPR_OP_MULT,
+ make_cellref (1,-5));
+ expr_sqrt = gnm_expr_new_funcall1
+ (fd_sqrt,
+ gnm_expr_new_binary
+ (gnm_expr_new_binary
+ (gnm_expr_copy(expr_prod),
+ GNM_EXPR_OP_MULT,
+ gnm_expr_new_binary
+ (gnm_expr_new_binary
+ (make_cellref (0,-5),
+ GNM_EXPR_OP_ADD,
+ make_cellref (1,-5)),
+ GNM_EXPR_OP_ADD,
+ gnm_expr_new_constant (value_new_int (1)))),
+ GNM_EXPR_OP_DIV,
+ gnm_expr_new_constant (value_new_int (12))));
+ expr_normdist = gnm_expr_new_funcall4
+ (fd_normdist,
+ make_cellref (0,-1),
+ gnm_expr_new_binary
+ (expr_prod,
+ GNM_EXPR_OP_DIV,
+ gnm_expr_new_constant (value_new_int (2))),
+ expr_sqrt,
+ gnm_expr_new_constant (value_new_bool (TRUE)));
+
+ dao_set_cell_expr (dao, 1, 6,
+ gnm_expr_new_funcall2
+ (fd_min,
+ make_cellref (0,-4),
+ make_cellref (1,-4)));
+ dao_set_cell_expr (dao, 1, 7,
+ gnm_expr_new_funcall2
+ (fd_min,
+ make_cellref (0,-3),
+ make_cellref (1,-3)));
+
+ dao_set_cell_expr (dao, 1, 8,
+ gnm_expr_new_binary
+ (gnm_expr_new_constant (value_new_int (2)),
+ GNM_EXPR_OP_MULT,
+ expr_normdist));
+ dao_set_cell_comment (dao, 1, 8,
+ _("This p-value is calulated using a\n"
+ "normal approximation, so it is\n"
+ "only valid for large samples of\n"
+ "at least 15 observations in each\n"
+ "population, and few if any ties."));
+ } else {
+ dao_set_cell_na (dao, 1, 6);
+ dao_set_cell_comment (dao, 1, 6,
+ _("Since there is insufficient space\n"
+ "for the third column of output,\n"
+ "this value is not calculated."));
+ dao_set_cell_na (dao, 1, 7);
+ dao_set_cell_comment (dao, 1, 7,
+ _("Since there is insufficient space\n"
+ "for the third column of output,\n"
+ "this value is not calculated."));
+ dao_set_cell_na (dao, 1, 8);
+ dao_set_cell_comment (dao, 1, 8,
+ _("Since there is insufficient space\n"
+ "for the third column of output,\n"
+ "this value is not calculated."));
+ }
+
+
+ gnm_expr_free (expr_count_total);
+
+ gnm_expr_free (expr_total);
+
+ gnm_func_unref (fd_count);
+ gnm_func_unref (fd_sum);
+ gnm_func_unref (fd_rows);
+ gnm_func_unref (fd_rank_avg);
+ gnm_func_unref (fd_rank);
+ gnm_func_unref (fd_min);
+ gnm_func_unref (fd_normdist);
+ gnm_func_unref (fd_sqrt);
+ gnm_func_unref (fd_if);
+ gnm_func_unref (fd_isblank);
+
+ dao_redraw_respan (dao);
+ return 0;
+}
+
+gboolean
+analysis_tool_wilcoxon_mann_whitney_engine
+ (data_analysis_output_t *dao, gpointer specs,
+ analysis_tool_engine_t selector, gpointer result)
+{
+ switch (selector) {
+ case TOOL_ENGINE_UPDATE_DESCRIPTOR:
+ return (dao_command_descriptor
+ (dao, _("Wilcoxon-Mann-Whitney Test (%s)"), result)
+ == NULL);
+ case TOOL_ENGINE_UPDATE_DAO:
+ dao_adjust (dao, 4, 9);
+ 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, _("Wilcoxon-Mann-Whitney Test"));
+ return FALSE;
+ case TOOL_ENGINE_FORMAT_OUTPUT_RANGE:
+ return dao_format_output (dao, _("Wilcoxon-Mann-Whitney Test"));
+ case TOOL_ENGINE_PERFORM_CALC:
+ default:
+ return analysis_tool_wilcoxon_mann_whitney_engine_run (dao, specs);
+ }
+ return TRUE; /* We shouldn't get here */
+}
diff --git a/src/tools/analysis-wilcoxon-mann-whitney.h b/src/tools/analysis-wilcoxon-mann-whitney.h
new file mode 100644
index 0000000..1814b60
--- /dev/null
+++ b/src/tools/analysis-wilcoxon-mann-whitney.h
@@ -0,0 +1,42 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * analysis-wilcoxon-mann-whitney.h:
+ *
+ * Author:
+ * Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ * (C) Copyright 2010 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_WILCOXON_MANN_WHITNEY_H
+#define ANALYSIS_WILCOXON_MANN_WHITNEY_H
+
+#include "gnumeric.h"
+#include "numbers.h"
+#include "dao.h"
+#include "tools.h"
+#include "analysis-tools.h"
+#include "sheet.h"
+
+gboolean analysis_tool_wilcoxon_mann_whitney_engine
+ (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 5e8f08a..f911aa3 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -891,6 +891,7 @@ static GNM_ACTION_DEF (cb_tools_regression) { dialog_regression_tool (wbcg, wbcg
static GNM_ACTION_DEF (cb_tools_sampling) { dialog_sampling_tool (wbcg, wbcg_cur_sheet (wbcg)); }
static GNM_ACTION_DEF (cb_tools_sign_test_one_median) { dialog_sign_test_tool (wbcg, wbcg_cur_sheet (wbcg), SIGNTEST_1); }
static GNM_ACTION_DEF (cb_tools_sign_test_two_medians) { dialog_sign_test_tool (wbcg, wbcg_cur_sheet (wbcg), SIGNTEST_2); }
+static GNM_ACTION_DEF (cb_tools_wilcoxon_mann_whitney) { dialog_wilcoxon_m_w_tool (wbcg, wbcg_cur_sheet (wbcg)); }
static GNM_ACTION_DEF (cb_tools_ttest_paired) { dialog_ttest_tool (wbcg, wbcg_cur_sheet (wbcg), TTEST_PAIRED); }
static GNM_ACTION_DEF (cb_tools_ttest_equal_var) { dialog_ttest_tool (wbcg, wbcg_cur_sheet (wbcg), TTEST_UNPAIRED_EQUALVARIANCES); }
static GNM_ACTION_DEF (cb_tools_ttest_unequal_var) { dialog_ttest_tool (wbcg, wbcg_cur_sheet (wbcg), TTEST_UNPAIRED_UNEQUALVARIANCES); }
@@ -1737,6 +1738,7 @@ static GtkActionEntry const permanent_actions[] = {
{ "MenuContingencyTests", NULL, N_("Contin_gency Table") },
{ "MenuToolForecast", NULL, N_("F_orecast") },
{ "MenuToolFrequencies", NULL, N_("Fre_quency Tables") },
+ { "MenuToolTwoMedians", NULL, N_("Two _Medians") },
{ "MenuToolTTest", NULL, N_("Two _Means") },
{ "MenuData", NULL, N_("_Data") },
{ "MenuFilter", NULL, N_("_Filter") },
@@ -2148,7 +2150,7 @@ static GtkActionEntry const actions[] = {
NULL, N_("Various frequency tables for numeric data"),
G_CALLBACK (cb_tools_histogram) },
-/* Tools -> Two Means */
+/* Tools -> Analysis -> Two Means */
{ "ToolTTestPaired", NULL, N_("_Paired Samples: T-Test..."),
NULL, N_("Comparing two population means for two paired samples: t-test..."),
G_CALLBACK (cb_tools_ttest_paired) },
@@ -2165,6 +2167,15 @@ static GtkActionEntry const actions[] = {
NULL, N_("Comparing two population means from populations with known variances: z-test..."),
G_CALLBACK (cb_tools_ztest) },
+/* Tools -> Analysis -> Two Medias */
+
+ { "ToolsTwoMedianSignTest", NULL, N_("_Sign Test..."),
+ NULL, N_("Comparing the values of two medians of paired observations"),
+ G_CALLBACK (cb_tools_sign_test_two_medians) },
+ { "ToolsTwoMedianWilcoxonMannWhitney", NULL, N_("_Wilcoxon-Mann-Whitney..."),
+ NULL, N_("Comparing the values of two medians of unpaired observations"),
+ G_CALLBACK (cb_tools_wilcoxon_mann_whitney) },
+
/* Tools -> Analysis */
{ "ToolsCorrelation", NULL, N_("_Correlation..."),
NULL, N_("Pearson Correlation"),
@@ -2203,9 +2214,6 @@ static GtkActionEntry const actions[] = {
{ "ToolsOneMedianSignTest", NULL, N_("One M_edian Sign Test..."),
NULL, N_("Testing the value of a median"),
G_CALLBACK (cb_tools_sign_test_one_median) },
- { "ToolsTwoMedianSignTest", NULL, N_("T_wo Medians Sign Test..."),
- NULL, N_("Comparing the values of two medians"),
- G_CALLBACK (cb_tools_sign_test_two_medians) },
/* Data */
{ "DataSort", GTK_STOCK_SORT_ASCENDING, N_("_Sort..."),
NULL, N_("Sort the selected region"),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]