[gnumeric] Add two-medians sign test
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] Add two-medians sign test
- Date: Tue, 15 Dec 2009 07:20:14 +0000 (UTC)
commit 9d17c364c6f15d2ac707842ea66b7170fef01f4c
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Tue Dec 15 00:14:20 2009 -0700
Add two-medians sign test
2009-12-15 Andreas J. Guelzow <aguelzow pyrshep ca>
* POTFILES.skip: added src/dialogs/sign-test-two.glade
2009-12-15 Andreas J. Guelzow <aguelzow pyrshep ca>
* POTFILES.in: added src/dialogs/sign-test-two.glade
2009-12-15 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-analysis-tool-sign-test.c
(sign_test_tool_update_sensitivity_cb): also handle 2
medians case
(sign_test_two_tool_ok_clicked_cb): new
(dialog_sign_test_tool): change argument type and also
handle 2-medians case
* dialog-analysis-tool-sign-test.h
(dialog_sign_test_tool): change argument type
* sign-test-two.glade: new
* Makefile.am: add sign-test-two.glade
* dialogs.h (dialog_sign_test_tool): change argument type
* help.h: add GNUMERIC_HELP_LINK_SIGN_TEST
2009-12-15 Andreas J. Guelzow <aguelzow pyrshep ca>
* component/Gnumeric-embed.xml.in: add 2 medians sign test
* src/HILDON_Gnumeric-gtk.xml.in: add 2 medians sign test
* src/GNOME_Gnumeric-gtk.xml.in: add 2 medians sign test
* src/wbc-gtk-actions.c: add 2 medians sign test action
2009-12-15 Andreas J. Guelzow <aguelzow pyrshep ca>
* analysis-sign-test.c (analysis_tool_sign_test_engine_run): simplify
(analysis_tool_sign_test_two_engine_run): new
(gboolean analysis_tool_sign_test_two_engine): new
* analysis-sign-test.h (analysis_tools_data_sign_test_two_t): new
(gboolean analysis_tool_sign_test_two_engine): new
* analysis-tools.h (analysis_tools_write_label_ftest): new
* analysis-tools.c (analysis_tools_write_label_ftest): make public
ChangeLog | 7 +
component/Gnumeric-embed.xml.in | 1 +
po-functions/ChangeLog | 4 +
po-functions/POTFILES.skip | 1 +
po/ChangeLog | 4 +
po/POTFILES.in | 1 +
src/GNOME_Gnumeric-gtk.xml.in | 1 +
src/HILDON_Gnumeric-gtk.xml.in | 1 +
src/dialogs/ChangeLog | 15 ++
src/dialogs/Makefile.am | 3 +-
src/dialogs/dialog-analysis-tool-sign-test.c | 97 ++++++++--
src/dialogs/dialogs.h | 8 +-
src/dialogs/sign-test-two.glade | 281 ++++++++++++++++++++++++++
src/tools/ChangeLog | 10 +
src/tools/analysis-sign-test.c | 203 ++++++++++++++++++-
src/tools/analysis-sign-test.h | 7 +
src/tools/analysis-tools.c | 4 +-
src/tools/analysis-tools.h | 3 +
src/wbc-gtk-actions.c | 9 +-
19 files changed, 632 insertions(+), 28 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2913230..bb45173 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-12-15 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * component/Gnumeric-embed.xml.in: add 2 medians sign test
+ * src/HILDON_Gnumeric-gtk.xml.in: add 2 medians sign test
+ * src/GNOME_Gnumeric-gtk.xml.in: add 2 medians sign test
+ * src/wbc-gtk-actions.c: add 2 medians sign test action
+
2009-12-14 Jean Brefort <jean brefort normalesup org>
* src/sheet-object-cell-comment.c (comment_view_set_bounds): make the
diff --git a/component/Gnumeric-embed.xml.in b/component/Gnumeric-embed.xml.in
index 8fcd5f4..2693d15 100644
--- a/component/Gnumeric-embed.xml.in
+++ b/component/Gnumeric-embed.xml.in
@@ -188,6 +188,7 @@
<menuitem action="ToolsRegression"/>
<menuitem action="ToolsSampling"/>
<menuitem action="ToolsOneMedianSignTest"/>
+ <menuitem action="ToolsTwoMedianSignTest"/>
<menu name="ToolTTest" action="MenuToolTTest">
<menuitem action="ToolTTestPaired"/>
<menuitem action="ToolTTestEqualVar"/>
diff --git a/po-functions/ChangeLog b/po-functions/ChangeLog
index e9392a9..2c99e18 100644
--- a/po-functions/ChangeLog
+++ b/po-functions/ChangeLog
@@ -1,5 +1,9 @@
2009-12-11 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * POTFILES.skip: added src/dialogs/sign-test-two.glade
+
+2009-12-11 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* POTFILES.in: added src/dialogs/dialog-analysis-tool-sign-test.c
and src/tools/analysis-sign-test.c
* POTFILES.skip: added src/dialogs/sign-test.glade
diff --git a/po-functions/POTFILES.skip b/po-functions/POTFILES.skip
index 8b1991c..6a28373 100644
--- a/po-functions/POTFILES.skip
+++ b/po-functions/POTFILES.skip
@@ -129,6 +129,7 @@ src/dialogs/sheet-resize.glade
src/dialogs/shuffle.glade
src/dialogs/simulation.glade
src/dialogs/sign-test.glade
+src/dialogs/sign-test-two.glade
src/dialogs/so-button.glade
src/dialogs/so-checkbox.glade
src/dialogs/so-frame.glade
diff --git a/po/ChangeLog b/po/ChangeLog
index 5de3bb1..8b36f65 100644
--- a/po/ChangeLog
+++ b/po/ChangeLog
@@ -1,3 +1,7 @@
+2009-12-15 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * POTFILES.in: added src/dialogs/sign-test-two.glade
+
2009-12-11 Andreas J. Guelzow <aguelzow pyrshep ca>
* POTFILES.in: added src/dialogs/dialog-analysis-tool-sign-test.c,
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1b116de..9c7da09 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -254,6 +254,7 @@ src/dialogs/sheet-resize.glade
src/dialogs/shuffle.glade
src/dialogs/simulation.glade
src/dialogs/sign-test.glade
+src/dialogs/sign-test-two.glade
src/dialogs/so-button.glade
src/dialogs/so-checkbox.glade
src/dialogs/so-frame.glade
diff --git a/src/GNOME_Gnumeric-gtk.xml.in b/src/GNOME_Gnumeric-gtk.xml.in
index b6d11b7..3db4f1a 100644
--- a/src/GNOME_Gnumeric-gtk.xml.in
+++ b/src/GNOME_Gnumeric-gtk.xml.in
@@ -187,6 +187,7 @@
<menuitem action="ToolsRegression"/>
<menuitem action="ToolsSampling"/>
<menuitem action="ToolsOneMedianSignTest"/>
+ <menuitem action="ToolsTwoMedianSignTest"/>
<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 b7c9a17..a9752b7 100644
--- a/src/HILDON_Gnumeric-gtk.xml.in
+++ b/src/HILDON_Gnumeric-gtk.xml.in
@@ -193,6 +193,7 @@
<menuitem action="ToolsRegression"/>
<menuitem action="ToolsSampling"/>
<menuitem action="ToolsOneMedianSignTest"/>
+ <menuitem action="ToolsTwoMedianSignTest"/>
<menu name="ToolTTest" action="MenuToolTTest">
<menuitem action="ToolTTestPaired"/>
<menuitem action="ToolTTestEqualVar"/>
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 5c06eea..afac366 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,18 @@
+2009-12-15 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * dialog-analysis-tool-sign-test.c
+ (sign_test_tool_update_sensitivity_cb): also handle 2
+ medians case
+ (sign_test_two_tool_ok_clicked_cb): new
+ (dialog_sign_test_tool): change argument type and also
+ handle 2-medians case
+ * dialog-analysis-tool-sign-test.h
+ (dialog_sign_test_tool): change argument type
+ * sign-test-two.glade: new
+ * Makefile.am: add sign-test-two.glade
+ * dialogs.h (dialog_sign_test_tool): change argument type
+ * help.h: add GNUMERIC_HELP_LINK_SIGN_TEST
+
2009-12-11 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-analysis-tool-sign-test.c (dialog_sign_test_tool):
diff --git a/src/dialogs/Makefile.am b/src/dialogs/Makefile.am
index 37f9df1..43c44b0 100644
--- a/src/dialogs/Makefile.am
+++ b/src/dialogs/Makefile.am
@@ -137,7 +137,8 @@ glade_DATA = \
merge.glade \
moving-averages.glade \
normality-tests.glade \
- sign-test.glade \
+ sign-test.glade \
+ sign-test-two.glade \
paste-names.glade \
plugin-manager.glade \
preferences.glade \
diff --git a/src/dialogs/dialog-analysis-tool-sign-test.c b/src/dialogs/dialog-analysis-tool-sign-test.c
index 3631a0c..3ee8a26 100644
--- a/src/dialogs/dialog-analysis-tool-sign-test.c
+++ b/src/dialogs/dialog-analysis-tool-sign-test.c
@@ -54,7 +54,8 @@
#include <string.h>
#include <gtk/gtk.h>
-#define SIGN_TEST_KEY "analysistools-sign-test-dialog"
+#define SIGN_TEST_KEY_ONE "analysistools-sign-test-one-dialog"
+#define SIGN_TEST_KEY_TWO "analysistools-sign-test-two-dialog"
static char const * const grouped_by_group[] = {
"grouped_by_row",
@@ -85,17 +86,34 @@ sign_test_tool_update_sensitivity_cb (G_GNUC_UNUSED GtkWidget *dummy,
GSList *input_range;
gboolean err;
+ /* 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),
- _("The input range is invalid."));
+ (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);
+ /* Checking second input range*/
+ if (state->base.input_entry_2 != NULL) {
+ input_range = gnm_expr_entry_parse_as_list
+ (GNM_EXPR_ENTRY (state->base.input_entry_2),
+ state->base.sheet);
+ if (input_range == NULL) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning),
+ _("The second input range is invalid."));
+ gtk_widget_set_sensitive (state->base.ok_button, FALSE);
+ return;
+ } else
+ range_list_destroy (input_range);
+ }
+
/* Checking Median*/
err = entry_to_float
(GTK_ENTRY (state->median_entry), &median, FALSE);
@@ -156,15 +174,13 @@ sign_test_tool_ok_clicked_cb (G_GNUC_UNUSED GtkWidget *button,
data->base.input = gnm_expr_entry_parse_as_list (
GNM_EXPR_ENTRY (state->base.input_entry), state->base.sheet);
data->base.group_by = gnumeric_glade_group_value (state->base.gui, grouped_by_group);
-
+
w = glade_xml_get_widget (state->base.gui, "labels_button");
data->base.labels = gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (w));
- data->median = 0.;
err = entry_to_float
(GTK_ENTRY (state->median_entry), &data->median, FALSE);
-
data->alpha = gtk_spin_button_get_value
(GTK_SPIN_BUTTON (state->alpha_entry));
@@ -175,6 +191,41 @@ sign_test_tool_ok_clicked_cb (G_GNUC_UNUSED GtkWidget *button,
return;
}
+static void
+sign_test_two_tool_ok_clicked_cb (G_GNUC_UNUSED GtkWidget *button,
+ SignTestToolState *state)
+{
+ data_analysis_output_t *dao;
+ GtkWidget *w;
+ analysis_tools_data_sign_test_two_t *data;
+ gboolean err;
+
+ data = g_new0 (analysis_tools_data_sign_test_two_t, 1);
+ dao = parse_output ((GenericToolState *)state, NULL);
+
+ data->base.range_1 = gnm_expr_entry_parse_as_value
+ (GNM_EXPR_ENTRY (state->base.input_entry), state->base.sheet);
+
+ data->base.range_2 = gnm_expr_entry_parse_as_value
+ (GNM_EXPR_ENTRY (state->base.input_entry_2), state->base.sheet);
+
+ w = glade_xml_get_widget (state->base.gui, "labels_button");
+ data->base.labels = gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (w));
+
+ err = entry_to_float
+ (GTK_ENTRY (state->median_entry), &data->median, FALSE);
+
+ data->base.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_sign_test_two_engine))
+ gtk_widget_destroy (state->base.dialog);
+
+ return;
+}
+
/**
* dialog_sign_test_tool:
* @wbcg:
@@ -184,36 +235,54 @@ sign_test_tool_ok_clicked_cb (G_GNUC_UNUSED GtkWidget *button,
*
**/
int
-dialog_sign_test_tool (WBCGtk *wbcg, Sheet *sheet, G_GNUC_UNUSED int n_median)
+dialog_sign_test_tool (WBCGtk *wbcg, Sheet *sheet, signtest_type n_median)
{
- SignTestToolState *state;
+ char const *key, *glade;
char const * plugins[] = { "Gnumeric_fnstat",
"Gnumeric_fnlogical",
"Gnumeric_fnmath",
"Gnumeric_fninfo",
NULL};
+ SignTestToolState *state;
+ GnmExprEntryFlags flags = 0;
+ GCallback cb;
if ((wbcg == NULL) ||
gnm_check_for_plugins_missing (plugins, wbcg_toplevel (wbcg)))
return 1;
+
+ switch (n_median) {
+ case SIGNTEST_2:
+ key = SIGN_TEST_KEY_TWO;
+ glade = "sign-test-two.glade";
+ flags = GNM_EE_SINGLE_RANGE;
+ cb = G_CALLBACK (sign_test_two_tool_ok_clicked_cb);
+ break;
+ case SIGNTEST_1:
+ default:
+ key = SIGN_TEST_KEY_ONE;
+ glade = "sign-test.glade";
+ cb = G_CALLBACK (sign_test_tool_ok_clicked_cb);
+ break;
+ }
+
/* Only pop up one copy per workbook */
- if (gnumeric_dialog_raise_if_exists (wbcg, SIGN_TEST_KEY))
+ if (gnumeric_dialog_raise_if_exists (wbcg, key))
return 0;
state = g_new0 (SignTestToolState, 1);
if (dialog_tool_init (&state->base, wbcg, sheet,
GNUMERIC_HELP_LINK_SIGN_TEST,
- "sign-test.glade", "Sign-Test",
+ glade, "Sign-Test",
_("Could not create the Sign Test Tool dialog."),
- SIGN_TEST_KEY,
- G_CALLBACK (sign_test_tool_ok_clicked_cb), NULL,
+ key, cb, NULL,
G_CALLBACK (sign_test_tool_update_sensitivity_cb),
- 0))
+ flags))
return 0;
-
+
state->alpha_entry = glade_xml_get_widget (state->base.gui,
"alpha-entry");
float_to_entry (GTK_ENTRY (state->alpha_entry), 0.05);
@@ -236,5 +305,5 @@ dialog_sign_test_tool (WBCGtk *wbcg, Sheet *sheet, G_GNUC_UNUSED int n_median)
sign_test_tool_update_sensitivity_cb (NULL, state);
tool_load_selection ((GenericToolState *)state, TRUE);
- return 0;
+ return 0;
}
diff --git a/src/dialogs/dialogs.h b/src/dialogs/dialogs.h
index f866596..5c2fe22 100644
--- a/src/dialogs/dialogs.h
+++ b/src/dialogs/dialogs.h
@@ -93,7 +93,13 @@ 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_chi_square_tool (WBCGtk *wbcg, Sheet *sheet, gboolean independence);
-int dialog_sign_test_tool (WBCGtk *wbcg, Sheet *sheet, int n_medians);
+
+typedef enum {
+ SIGNTEST_1 = 1,
+ SIGNTEST_2 = 2
+} signtest_type;
+
+int dialog_sign_test_tool (WBCGtk *wbcg, Sheet *sheet, signtest_type n_medians);
typedef enum {
TTEST_PAIRED = 1,
diff --git a/src/dialogs/sign-test-two.glade b/src/dialogs/sign-test-two.glade
new file mode 100644
index 0000000..6587c79
--- /dev/null
+++ b/src/dialogs/sign-test-two.glade
@@ -0,0 +1,281 @@
+<?xml version="1.0"?>
+<glade-interface>
+ <!-- interface-requires gtk+ 2.6 -->
+ <!-- interface-naming-policy toplevel-contextual -->
+ <widget class="GtkDialog" id="Sign-Test">
+ <property name="title" translatable="yes">Testing the Difference of 2 Means</property>
+ <property name="type_hint">normal</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="spacing">8</property>
+ <child>
+ <widget class="GtkNotebook" id="notebook1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <widget class="GtkTable" id="input-table">
+ <property name="visible">True</property>
+ <property name="border_width">12</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">12</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <widget class="GtkLabel" id="var1-label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="xpad">5</property>
+ <property name="label" translatable="yes">Variable _1 range:</property>
+ <property name="use_underline">True</property>
+ <property name="justify">right</property>
+ </widget>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="var2-label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="xpad">5</property>
+ <property name="label" translatable="yes">Variable _2 range:</property>
+ <property name="use_underline">True</property>
+ <property name="justify">right</property>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkCheckButton" id="labels_button">
+ <property name="label" translatable="yes">_Labels</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Input</property>
+ <property name="use_underline">True</property>
+ </widget>
+ <packing>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkTable" id="table3">
+ <property name="visible">True</property>
+ <property name="border_width">12</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">12</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <widget class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="xpad">5</property>
+ <property name="label" translatable="yes">Hypothesized _difference of medians:</property>
+ <property name="use_underline">True</property>
+ <property name="justify">right</property>
+ <property name="mnemonic_widget">median-entry</property>
+ </widget>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="xpad">5</property>
+ <property name="label" translatable="yes">_Alpha:</property>
+ <property name="use_underline">True</property>
+ <property name="justify">right</property>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="median-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="activates_default">True</property>
+ <property name="text" translatable="yes">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkSpinButton" id="alpha-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="adjustment">0.050000000000000003 0 1 0.01 10 0</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>
+ </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"></property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Test</property>
+ <property name="use_underline">True</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="dao">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label12">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Output</property>
+ <property name="use_underline">True</property>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="warnings">
+ <property name="visible">True</property>
+ <property name="use_markup">True</property>
+ <property name="wrap">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="hbuttonbox1">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <widget class="GtkButton" id="helpbutton">
+ <property name="label">gtk-help</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_stock">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="cancelbutton">
+ <property name="label">gtk-cancel</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_stock">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="okbutton">
+ <property name="label">gtk-ok</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_stock">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
diff --git a/src/tools/ChangeLog b/src/tools/ChangeLog
index 516cc75..e1ae938 100644
--- a/src/tools/ChangeLog
+++ b/src/tools/ChangeLog
@@ -1,3 +1,13 @@
+2009-12-15 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * analysis-sign-test.c (analysis_tool_sign_test_engine_run): simplify
+ (analysis_tool_sign_test_two_engine_run): new
+ (gboolean analysis_tool_sign_test_two_engine): new
+ * analysis-sign-test.h (analysis_tools_data_sign_test_two_t): new
+ (gboolean analysis_tool_sign_test_two_engine): new
+ * analysis-tools.h (analysis_tools_write_label_ftest): new
+ * analysis-tools.c (analysis_tools_write_label_ftest): make public
+
2009-12-11 Andreas J. Guelzow <aguelzow pyrshep ca>
* analysis-sign-test.c (analysis_tool_sign_test_engine_run):
diff --git a/src/tools/analysis-sign-test.c b/src/tools/analysis-sign-test.c
index 46d5fa8..2fca6da 100644
--- a/src/tools/analysis-sign-test.c
+++ b/src/tools/analysis-sign-test.c
@@ -82,10 +82,12 @@ analysis_tool_sign_test_engine_run (data_analysis_output_t *dao,
for (col = 0; data != NULL; data = data->next, col++) {
GnmValue *val_org = value_dup (data->data);
+ GnmExpr const *expr_org;
/* Note that analysis_tools_write_label may modify val_org */
dao_set_italic (dao, col + 1, 0, col+1, 0);
analysis_tools_write_label (val_org, dao, &info->base, col + 1, 0, col + 1);
+ expr_org = gnm_expr_new_constant (val_org);
if (first) {
dao_set_cell_float (dao, col + 1, 2, info->median);
@@ -98,13 +100,13 @@ analysis_tool_sign_test_engine_run (data_analysis_output_t *dao,
expr_isnumber = gnm_expr_new_funcall3
(fd_if, gnm_expr_new_funcall1
- (fd_isnumber, gnm_expr_new_constant (value_dup (val_org))),
+ (fd_isnumber, gnm_expr_copy (expr_org)),
gnm_expr_new_constant (value_new_int (1)),
gnm_expr_new_constant (value_new_int (0)));
expr = gnm_expr_new_funcall1
(fd_median,
- gnm_expr_new_constant (value_dup (val_org)));
+ gnm_expr_copy (expr_org));
dao_set_cell_expr (dao, col + 1, 1, expr);
expr_neg = gnm_expr_new_funcall1
@@ -114,7 +116,7 @@ analysis_tool_sign_test_engine_run (data_analysis_output_t *dao,
gnm_expr_new_funcall2
(fd_iferror,
gnm_expr_new_funcall3
- (fd_if, gnm_expr_new_binary (gnm_expr_new_constant (value_dup (val_org)),
+ (fd_if, gnm_expr_new_binary (gnm_expr_copy (expr_org),
GNM_EXPR_OP_LT, make_cellref (0,-1)),
gnm_expr_new_constant (value_new_int (1)),
gnm_expr_new_constant (value_new_int (0))),
@@ -126,7 +128,7 @@ analysis_tool_sign_test_engine_run (data_analysis_output_t *dao,
gnm_expr_new_funcall2
(fd_iferror,
gnm_expr_new_funcall3
- (fd_if, gnm_expr_new_binary (gnm_expr_new_constant (value_dup (val_org)),
+ (fd_if, gnm_expr_new_binary (gnm_expr_copy (expr_org),
GNM_EXPR_OP_GT, make_cellref (0,-1)),
gnm_expr_new_constant (value_new_int (1)),
gnm_expr_new_constant (value_new_int (0))),
@@ -140,7 +142,7 @@ analysis_tool_sign_test_engine_run (data_analysis_output_t *dao,
(expr_isnumber, GNM_EXPR_OP_MULT,
gnm_expr_new_funcall2
(fd_iferror, gnm_expr_new_funcall3
- (fd_if, gnm_expr_new_binary (gnm_expr_new_constant (value_dup (val_org)),
+ (fd_if, gnm_expr_new_binary (expr_org,
GNM_EXPR_OP_NOT_EQUAL, make_cellref (0,-2)),
gnm_expr_new_constant (value_new_int (1)),
gnm_expr_new_constant (value_new_int (0))),
@@ -155,8 +157,6 @@ analysis_tool_sign_test_engine_run (data_analysis_output_t *dao,
expr = gnm_expr_new_binary (gnm_expr_new_constant (value_new_int (2)),
GNM_EXPR_OP_MULT, make_cellref (0,-1));
dao_set_cell_array_expr (dao, col + 1, 7, expr);
-
- value_release (val_org);
}
gnm_func_unref (fd_median);
@@ -172,6 +172,167 @@ analysis_tool_sign_test_engine_run (data_analysis_output_t *dao,
return FALSE;
}
+static gboolean
+analysis_tool_sign_test_two_engine_run (data_analysis_output_t *dao,
+ analysis_tools_data_sign_test_two_t *info)
+{
+ GnmValue *val_1;
+ GnmValue *val_2;
+
+ GnmExpr const *expr_1;
+ GnmExpr const *expr_2;
+
+ GnmExpr const *expr;
+ GnmExpr const *expr_diff;
+ GnmExpr const *expr_neg;
+ GnmExpr const *expr_pos;
+ GnmExpr const *expr_isnumber_1;
+ GnmExpr const *expr_isnumber_2;
+
+ GnmFunc *fd_median;
+ GnmFunc *fd_if;
+ GnmFunc *fd_sum;
+ GnmFunc *fd_min;
+ GnmFunc *fd_binomdist;
+ GnmFunc *fd_isnumber;
+ GnmFunc *fd_iferror;
+
+ fd_median = gnm_func_lookup_or_add_placeholder ("MEDIAN", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_median);
+ fd_if = gnm_func_lookup_or_add_placeholder ("IF", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_if);
+ fd_sum = gnm_func_lookup_or_add_placeholder ("SUM", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_sum);
+ fd_min = gnm_func_lookup_or_add_placeholder ("MIN", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_min);
+ fd_binomdist = gnm_func_lookup_or_add_placeholder ("BINOMDIST", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_binomdist);
+ fd_isnumber = gnm_func_lookup_or_add_placeholder ("ISNUMBER", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_isnumber);
+ 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, _("/Sign Test"
+ "/Median:"
+ "/Predicted Difference:"
+ "/Test Statistic:"
+ "/N:"
+ "/\xce\xb1:"
+ "/P(T\xe2\x89\xa4t) one-tailed:"
+ "/P(T\xe2\x89\xa4t) two-tailed:"));
+
+ val_1 = value_dup (info->base.range_1);
+ val_2 = value_dup (info->base.range_2);
+
+ /* Labels */
+ dao_set_italic (dao, 1, 0, 2, 0);
+ analysis_tools_write_label_ftest (val_1, dao, 1, 0,
+ info->base.labels, 1);
+ analysis_tools_write_label_ftest (val_2, dao, 2, 0,
+ info->base.labels, 2);
+
+ expr_1 = gnm_expr_new_constant (value_dup (val_1));
+ expr_2 = gnm_expr_new_constant (value_dup (val_2));
+
+ dao_set_cell_float (dao, 1, 2, info->median);
+ dao_set_cell_float (dao, 1, 5, info->base.alpha);
+
+ expr = gnm_expr_new_funcall1
+ (fd_median,
+ gnm_expr_copy (expr_1));
+ dao_set_cell_expr (dao, 1, 1, expr);
+
+ expr = gnm_expr_new_funcall1
+ (fd_median,
+ gnm_expr_copy (expr_2));
+ dao_set_cell_expr (dao, 2, 1, expr);
+
+ expr_diff = gnm_expr_new_binary (gnm_expr_copy (expr_1),
+ GNM_EXPR_OP_SUB,
+ gnm_expr_copy (expr_2));
+
+ expr_isnumber_1 = gnm_expr_new_funcall3
+ (fd_if, gnm_expr_new_funcall1
+ (fd_isnumber, expr_1),
+ gnm_expr_new_constant (value_new_int (1)),
+ gnm_expr_new_constant (value_new_int (0)));
+ expr_isnumber_2 = gnm_expr_new_funcall3
+ (fd_if, gnm_expr_new_funcall1
+ (fd_isnumber, expr_2),
+ gnm_expr_new_constant (value_new_int (1)),
+ gnm_expr_new_constant (value_new_int (0)));
+
+ expr_neg = gnm_expr_new_funcall1
+ (fd_sum,
+ gnm_expr_new_binary
+ (gnm_expr_copy (expr_isnumber_1), GNM_EXPR_OP_MULT,
+ gnm_expr_new_binary
+ (gnm_expr_copy (expr_isnumber_1), GNM_EXPR_OP_MULT,
+ gnm_expr_new_funcall2
+ (fd_iferror,
+ gnm_expr_new_funcall3
+ (fd_if, gnm_expr_new_binary (gnm_expr_copy (expr_diff),
+ GNM_EXPR_OP_LT, make_cellref (0,-1)),
+ gnm_expr_new_constant (value_new_int (1)),
+ gnm_expr_new_constant (value_new_int (0))),
+ gnm_expr_new_constant (value_new_int (0))))));
+ expr_pos = gnm_expr_new_funcall1
+ (fd_sum,
+ gnm_expr_new_binary
+ (gnm_expr_copy (expr_isnumber_1), GNM_EXPR_OP_MULT,
+ gnm_expr_new_binary
+ (gnm_expr_copy (expr_isnumber_1), GNM_EXPR_OP_MULT,
+ gnm_expr_new_funcall2
+ (fd_iferror,
+ gnm_expr_new_funcall3
+ (fd_if, gnm_expr_new_binary (gnm_expr_copy (expr_diff),
+ GNM_EXPR_OP_GT, make_cellref (0,-1)),
+ gnm_expr_new_constant (value_new_int (1)),
+ gnm_expr_new_constant (value_new_int (0))),
+ gnm_expr_new_constant (value_new_int (0))))));
+ expr = gnm_expr_new_funcall2
+ (fd_min, expr_neg, expr_pos);
+ dao_set_cell_array_expr (dao, 1, 3, expr);
+
+ expr = gnm_expr_new_funcall1
+ (fd_sum, gnm_expr_new_binary
+ (expr_isnumber_1, GNM_EXPR_OP_MULT,
+ gnm_expr_new_binary
+ (expr_isnumber_2, GNM_EXPR_OP_MULT,
+ gnm_expr_new_funcall2
+ (fd_iferror, gnm_expr_new_funcall3
+ (fd_if, gnm_expr_new_binary (expr_diff,
+ GNM_EXPR_OP_NOT_EQUAL, make_cellref (0,-2)),
+ gnm_expr_new_constant (value_new_int (1)),
+ gnm_expr_new_constant (value_new_int (0))),
+ gnm_expr_new_constant (value_new_int (0))))));
+ dao_set_cell_array_expr (dao, 1, 4, expr);
+
+ expr = gnm_expr_new_funcall4 (fd_binomdist, make_cellref (0,-3), make_cellref (0,-2),
+ gnm_expr_new_constant (value_new_float (0.5)),
+ gnm_expr_new_constant (value_new_bool (TRUE)));
+ dao_set_cell_array_expr (dao, 1, 6, expr);
+
+ expr = gnm_expr_new_binary (gnm_expr_new_constant (value_new_int (2)),
+ GNM_EXPR_OP_MULT, make_cellref (0,-1));
+ dao_set_cell_array_expr (dao, 1, 7, expr);
+
+ gnm_func_unref (fd_median);
+ gnm_func_unref (fd_if);
+ gnm_func_unref (fd_min);
+ gnm_func_unref (fd_sum);
+ gnm_func_unref (fd_binomdist);
+ gnm_func_unref (fd_isnumber);
+ gnm_func_unref (fd_iferror);
+
+ value_release (val_1);
+ value_release (val_2);
+
+ dao_redraw_respan (dao);
+
+ return FALSE;
+}
gboolean
analysis_tool_sign_test_engine (data_analysis_output_t *dao, gpointer specs,
@@ -204,6 +365,34 @@ analysis_tool_sign_test_engine (data_analysis_output_t *dao, gpointer specs,
return TRUE;
}
+gboolean
+analysis_tool_sign_test_two_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, _("Sign Test (%s)"), result)
+ == NULL);
+ case TOOL_ENGINE_UPDATE_DAO:
+ dao_adjust (dao, 3, 8);
+ return FALSE;
+ case TOOL_ENGINE_CLEAN_UP:
+ return analysis_tool_generic_b_clean (specs);
+ case TOOL_ENGINE_LAST_VALIDITY_CHECK:
+ return FALSE;
+ case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
+ dao_prepare_output (NULL, dao, _("Sign Test"));
+ return FALSE;
+ case TOOL_ENGINE_FORMAT_OUTPUT_RANGE:
+ return dao_format_output (dao, _("Sign Test"));
+ case TOOL_ENGINE_PERFORM_CALC:
+ default:
+ return analysis_tool_sign_test_two_engine_run (dao, specs);
+ }
+ return TRUE; /* We shouldn't get here */
+}
+
diff --git a/src/tools/analysis-sign-test.h b/src/tools/analysis-sign-test.h
index e93ace0..c9e4e67 100644
--- a/src/tools/analysis-sign-test.h
+++ b/src/tools/analysis-sign-test.h
@@ -40,8 +40,15 @@ typedef struct {
gnm_float alpha;
} analysis_tools_data_sign_test_t;
+typedef struct {
+ analysis_tools_data_generic_b_t base;
+ gnm_float median;
+} analysis_tools_data_sign_test_two_t;
+
gboolean analysis_tool_sign_test_engine (data_analysis_output_t *dao, gpointer specs,
analysis_tool_engine_t selector, gpointer result);
+gboolean analysis_tool_sign_test_two_engine (data_analysis_output_t *dao, gpointer specs,
+ analysis_tool_engine_t selector, gpointer result);
#endif
diff --git a/src/tools/analysis-tools.c b/src/tools/analysis-tools.c
index b545920..b4416e3 100644
--- a/src/tools/analysis-tools.c
+++ b/src/tools/analysis-tools.c
@@ -201,7 +201,7 @@ analysis_tools_write_label (GnmValue *val, data_analysis_output_t *dao,
}
/*
- * analysis_tools_write_label:
+ * analysis_tools_write_label_ftest:
* @val: range to extract label from
* @dao: data_analysis_output_t, where to write to
* @info: analysis_tools_data_generic_t info
@@ -211,7 +211,7 @@ analysis_tools_write_label (GnmValue *val, data_analysis_output_t *dao,
*
*/
-static void
+void
analysis_tools_write_label_ftest (GnmValue *val, data_analysis_output_t *dao,
int x, int y, gboolean labels, int i)
{
diff --git a/src/tools/analysis-tools.h b/src/tools/analysis-tools.h
index 555f4c1..6248b35 100644
--- a/src/tools/analysis-tools.h
+++ b/src/tools/analysis-tools.h
@@ -212,6 +212,9 @@ 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 prepare_input_range (GSList **input_range, group_by_t group_by);
const GnmExpr *make_cellref (int dx, int dy);
diff --git a/src/wbc-gtk-actions.c b/src/wbc-gtk-actions.c
index 42d02b1..4b0cea0 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -883,7 +883,8 @@ static GNM_ACTION_DEF (cb_tools_normality_tests){ dialog_normality_tool (wbcg, w
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)); }
static GNM_ACTION_DEF (cb_tools_sampling) { dialog_sampling_tool (wbcg, wbcg_cur_sheet (wbcg)); }
-static GNM_ACTION_DEF (cb_tools_sign_test_one_mean) { dialog_sign_test_tool (wbcg, wbcg_cur_sheet (wbcg), 1); }
+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_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); }
@@ -2143,8 +2144,10 @@ static GtkActionEntry const actions[] = {
G_CALLBACK (cb_tools_normality_tests) },
{ "ToolsOneMedianSignTest", NULL, N_("One M_edian Sign Test..."),
NULL, N_("Testing the value of a median"),
- G_CALLBACK (cb_tools_sign_test_one_mean) },
-
+ 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]