Commit 9d17c364 authored by Andreas J. Guelzow 's avatar Andreas J. Guelzow

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
parent e92a4885
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
......
......@@ -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"/>
......
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
......
......@@ -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
......
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,
......
......@@ -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
......
......@@ -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"/>
......
......@@ -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"/>
......
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):
......
......@@ -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 \
......
......@@ -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;
}
......@@ -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,
......
<?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">&#x2022;</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>
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):
......
......@@ -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,