[gnumeric] Add normality test tool.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] Add normality test tool.
- Date: Sun, 22 Nov 2009 03:25:23 +0000 (UTC)
commit 01a88a2a91167683ffefda54b00cdf8f47c2fc1a
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Sat Nov 21 20:24:10 2009 -0700
Add normality test tool.
2009-11-21 Andreas J. Guelzow <aguelzow pyrshep ca>
* component/Gnumeric-embed.xml.in: add "Normality Test..." menu item
* src/GNOME_Gnumeric-gtk.xml.in: ditto
* src/HILDON_Gnumeric-gtk.xml.in: ditto
* src/wbc-gtk-actions.c (cb_tools_normality_tests): new
(ToolsNormalityTests) connect to cb_tools_normality_tests
2009-11-21 Andreas J. Guelzow <aguelzow pyrshep ca>
* analysis-normality.c: new
* analysis-normality.h: new
* Makefile.am: add analysis-normality.[ch]
* analysis-exp-smoothing.c: fix comment
* analysis-tools.h (analysis_tools_write_label): new
* analysis-tools.c (analysis_tools_write_label): make non-static
2009-11-21 Andreas J. Guelzow <aguelzow pyrshep ca>
* normality-tests.glade: new
* dialog-analysis-tool-normality.c: new
* Makefile.am: add dialog-analysis-tool-normality.c and
normality-tests.glade
* dialogs.h (dialog_normality_tool): new
* help.h: add GNUMERIC_HELP_LINK_NORMALITY
2009-11-11 Andreas J. Guelzow <aguelzow pyrshep ca>
* POTFILES.in: added dialog-analysis-tool-normality.c and
analysis-normality.c
2009-11-11 Andreas J. Guelzow <aguelzow pyrshep ca>
* POTFILES.in: added dialog-analysis-tool-normality.c and
analysis-normality.c
ChangeLog | 8 +
NEWS | 1 +
component/Gnumeric-embed.xml.in | 1 +
po-functions/ChangeLog | 5 +
po-functions/POTFILES.in | 2 +
po/ChangeLog | 5 +
po/POTFILES.in | 2 +
src/GNOME_Gnumeric-gtk.xml.in | 1 +
src/HILDON_Gnumeric-gtk.xml.in | 1 +
src/dialogs/ChangeLog | 9 +
src/dialogs/Makefile.am | 2 +
src/dialogs/dialog-analysis-tool-normality.c | 212 ++++++++++++++++
src/dialogs/dialogs.h | 1 +
src/dialogs/help.h | 3 +
src/dialogs/normality-tests.glade | 347 ++++++++++++++++++++++++++
src/tools/ChangeLog | 9 +
src/tools/Makefile.am | 2 +
src/tools/analysis-exp-smoothing.c | 2 +-
src/tools/analysis-normality.c | 153 +++++++++++
src/tools/analysis-normality.h | 48 ++++
src/tools/analysis-tools.c | 2 +-
src/tools/analysis-tools.h | 4 +-
src/wbc-gtk-actions.c | 4 +
23 files changed, 821 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6072458..c50443e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-11-21 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * component/Gnumeric-embed.xml.in: add "Normality Test..." menu item
+ * src/GNOME_Gnumeric-gtk.xml.in: ditto
+ * src/HILDON_Gnumeric-gtk.xml.in: ditto
+ * src/wbc-gtk-actions.c (cb_tools_normality_tests): new
+ (ToolsNormalityTests) connect to cb_tools_normality_tests
+
2009-11-18 Morten Welinder <terra gnome org>
* configure.in (gnomedb_msg): Disable gda if we don't have
diff --git a/NEWS b/NEWS
index fe974c9..5da5b8d 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Andreas:
* Temporarily remember the sort setups. [#100541]
* Work around GTK bug #601922.
* Add ADTEST (Anderson-Darling Test for Normality).
+ * Add normality test tools.
Jean:
* Fix cursor and cell edition on dark backgrounds. [#600656]
diff --git a/component/Gnumeric-embed.xml.in b/component/Gnumeric-embed.xml.in
index e471919..60a921a 100644
--- a/component/Gnumeric-embed.xml.in
+++ b/component/Gnumeric-embed.xml.in
@@ -183,6 +183,7 @@
<menuitem action="ToolsHistogram"/>
</menu>
<menuitem action="ToolsKaplanMeier"/>
+ <menuitem action="ToolsNormalityTests"/>
<menuitem action="ToolsRanking"/>
<menuitem action="ToolsRegression"/>
<menuitem action="ToolsSampling"/>
diff --git a/po-functions/ChangeLog b/po-functions/ChangeLog
index accdc18..2422335 100644
--- a/po-functions/ChangeLog
+++ b/po-functions/ChangeLog
@@ -1,3 +1,8 @@
+2009-11-11 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * POTFILES.in: added dialog-analysis-tool-normality.c and
+ analysis-normality.c
+
2009-11-05 Andreas J. Guelzow <aguelzow pyrshep ca>
* README.translators: new
diff --git a/po-functions/POTFILES.in b/po-functions/POTFILES.in
index 60b0885..b9ae069 100644
--- a/po-functions/POTFILES.in
+++ b/po-functions/POTFILES.in
@@ -76,6 +76,7 @@ src/dialogs/dialog-advanced-filter.c
src/dialogs/dialog-analysis-tool-chi-squared.c
src/dialogs/dialog-analysis-tool-frequency.c
src/dialogs/dialog-analysis-tool-kaplan-meier.c
+src/dialogs/dialog-analysis-tool-normality.c
src/dialogs/dialog-analysis-tools.c
src/dialogs/dialog-autofilter.c
src/dialogs/dialog-autoformat.c
@@ -194,6 +195,7 @@ src/tools/analysis-exp-smoothing.c
src/tools/analysis-frequency.c
src/tools/analysis-histogram.c
src/tools/analysis-kaplan-meier.c
+src/tools/analysis-normality.c
src/tools/analysis-tools.c
src/tools/dao.c
src/tools/data-shuffling.c
diff --git a/po/ChangeLog b/po/ChangeLog
index 1114a19..7f7de0c 100644
--- a/po/ChangeLog
+++ b/po/ChangeLog
@@ -1,3 +1,8 @@
+2009-11-11 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * POTFILES.in: added dialog-analysis-tool-normality.c and
+ analysis-normality.c
+
2009-11-01 Morten Welinder <terra gnome org>
* Release 1.9.15
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1950ceb..6bb346d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -156,6 +156,7 @@ src/dialogs/dialog-advanced-filter.c
src/dialogs/dialog-analysis-tool-chi-squared.c
src/dialogs/dialog-analysis-tool-frequency.c
src/dialogs/dialog-analysis-tool-kaplan-meier.c
+src/dialogs/dialog-analysis-tool-normality.c
src/dialogs/dialog-analysis-tools.c
src/dialogs/dialog-autofilter.c
src/dialogs/dialog-autoformat.c
@@ -324,6 +325,7 @@ src/tools/analysis-exp-smoothing.c
src/tools/analysis-frequency.c
src/tools/analysis-histogram.c
src/tools/analysis-kaplan-meier.c
+src/tools/analysis-normality.c
src/tools/analysis-tools.c
src/tools/dao.c
src/tools/data-shuffling.c
diff --git a/src/GNOME_Gnumeric-gtk.xml.in b/src/GNOME_Gnumeric-gtk.xml.in
index 740fb8d..0365a3a 100644
--- a/src/GNOME_Gnumeric-gtk.xml.in
+++ b/src/GNOME_Gnumeric-gtk.xml.in
@@ -182,6 +182,7 @@
<menuitem action="ToolsHistogram"/>
</menu>
<menuitem action="ToolsKaplanMeier"/>
+ <menuitem action="ToolsNormalityTests"/>
<menuitem action="ToolsRanking"/>
<menuitem action="ToolsRegression"/>
<menuitem action="ToolsSampling"/>
diff --git a/src/HILDON_Gnumeric-gtk.xml.in b/src/HILDON_Gnumeric-gtk.xml.in
index f9e1cb7..2206317 100644
--- a/src/HILDON_Gnumeric-gtk.xml.in
+++ b/src/HILDON_Gnumeric-gtk.xml.in
@@ -188,6 +188,7 @@
<menuitem action="ToolsHistogram"/>
</menu>
<menuitem action="ToolsKaplanMeier"/>
+ <menuitem action="ToolsNormalityTests"/>
<menuitem action="ToolsRanking"/>
<menuitem action="ToolsRegression"/>
<menuitem action="ToolsSampling"/>
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 7d1bf82..0e94bd0 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,12 @@
+2009-11-21 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * normality-tests.glade: new
+ * dialog-analysis-tool-normality.c: new
+ * Makefile.am: add dialog-analysis-tool-normality.c and
+ normality-tests.glade
+ * dialogs.h (dialog_normality_tool): new
+ * help.h: add GNUMERIC_HELP_LINK_NORMALITY
+
2009-11-14 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-cell-sort.c (cb_update_sensitivity): rename to
diff --git a/src/dialogs/Makefile.am b/src/dialogs/Makefile.am
index d4f8b1c..acff8d7 100644
--- a/src/dialogs/Makefile.am
+++ b/src/dialogs/Makefile.am
@@ -29,6 +29,7 @@ base_files = \
dialog-analysis-tool-chi-squared.c \
dialog-analysis-tool-frequency.c \
dialog-analysis-tool-kaplan-meier.c \
+ dialog-analysis-tool-normality.c \
dialog-autofilter.c \
dialog-autoformat.c \
dialog-autosave.c \
@@ -134,6 +135,7 @@ glade_DATA = \
mean-tests.glade \
merge.glade \
moving-averages.glade \
+ normality-tests.glade \
paste-names.glade \
plugin-manager.glade \
preferences.glade \
diff --git a/src/dialogs/dialog-analysis-tool-normality.c b/src/dialogs/dialog-analysis-tool-normality.c
new file mode 100644
index 0000000..0a9d447
--- /dev/null
+++ b/src/dialogs/dialog-analysis-tool-normality.c
@@ -0,0 +1,212 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * dialog-analysis-tool-normality.c:
+ *
+ * Authors:
+ * Andreas J. Guelzow <aguelzow taliesin ca>
+ *
+ * (C) Copyright 2009 by Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gnumeric-config.h>
+#include <glib/gi18n-lib.h>
+#include <gnumeric.h>
+#include "dialogs.h"
+#include "analysis-normality.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 NORMALITY_KEY "analysistools-normality-dialog"
+
+typedef struct {
+ GenericToolState base;
+ GtkWidget *alpha_entry;
+} NormalityTestsToolState;
+
+
+static char const * const grouped_by_group[] = {
+ "grouped_by_row",
+ "grouped_by_col",
+ "grouped_by_area",
+ NULL
+};
+
+/**
+ * normality_tool_update_sensitivity_cb:
+ * @dummy:
+ * @state:
+ *
+ * Update the dialog widgets sensitivity
+ **/
+static void
+normality_tool_update_sensitivity_cb (G_GNUC_UNUSED GtkWidget *dummy,
+ NormalityTestsToolState *state)
+{
+ gnm_float alpha;
+ GSList *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."));
+ gtk_widget_set_sensitive (state->base.ok_button, FALSE);
+ return;
+ } else
+ range_list_destroy (input_range);
+
+ /* Checking Alpha*/
+ alpha = gtk_spin_button_get_value
+ (GTK_SPIN_BUTTON (state->alpha_entry));
+ if (!(alpha > 0 && alpha < 1)) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning),
+ _("The alpha value should "
+ "be a number between 0 and 1."));
+ gtk_widget_set_sensitive (state->base.ok_button, FALSE);
+ return;
+ }
+
+ /* Checking Output Page */
+ if (!gnm_dao_is_ready (GNM_DAO (state->base.gdao))) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning),
+ _("The output specification "
+ "is invalid."));
+ gtk_widget_set_sensitive (state->base.ok_button, FALSE);
+ return;
+ }
+
+ gtk_label_set_text (GTK_LABEL (state->base.warning), "");
+ gtk_widget_set_sensitive (state->base.ok_button, TRUE);
+
+}
+
+
+/**
+ * normality_tool_ok_clicked_cb:
+ * @button:
+ * @state:
+ *
+ * Retrieve the information from the dialog and call the normality_tool.
+ * Note that we assume that the ok_button is only active if the entry fields
+ * contain sensible data.
+ **/
+static void
+normality_tool_ok_clicked_cb (G_GNUC_UNUSED GtkWidget *button,
+ NormalityTestsToolState *state)
+{
+ data_analysis_output_t *dao;
+ GtkWidget *w;
+ analysis_tools_data_normality_t *data;
+
+ data = g_new0 (analysis_tools_data_normality_t, 1);
+ dao = parse_output ((GenericToolState *)state, NULL);
+
+ data->base.input = gnm_expr_entry_parse_as_list (
+ GNM_EXPR_ENTRY (state->base.input_entry), state->base.sheet);
+ data->base.group_by = 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->alpha = gtk_spin_button_get_value
+ (GTK_SPIN_BUTTON (state->alpha_entry));
+
+ data->type = 'A';
+
+ if (!cmd_analysis_tool (WORKBOOK_CONTROL (state->base.wbcg), state->base.sheet,
+ dao, data, analysis_tool_normality_engine))
+ gtk_widget_destroy (state->base.dialog);
+
+ return;
+}
+
+/**
+ * dialog_normality_tool:
+ * @wbcg:
+ * @sheet:
+ *
+ * Show the dialog (guru).
+ *
+ **/
+int
+dialog_normality_tool (WBCGtk *wbcg, Sheet *sheet)
+{
+ NormalityTestsToolState *state;
+ char const * plugins[] = { "Gnumeric_fnstat",
+ "Gnumeric_fnlogical",
+ 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, NORMALITY_KEY))
+ return 0;
+
+ state = g_new0 (NormalityTestsToolState, 1);
+
+ if (dialog_tool_init (&state->base, wbcg, sheet,
+ GNUMERIC_HELP_LINK_NORMALITY,
+ "normality-tests.glade", "Normality-Tests",
+ _("Could not create the Normality Test Tool dialog."),
+ NORMALITY_KEY,
+ G_CALLBACK (normality_tool_ok_clicked_cb), NULL,
+ G_CALLBACK (normality_tool_update_sensitivity_cb),
+ 0))
+ return 0;
+
+
+ state->alpha_entry = glade_xml_get_widget (state->base.gui,
+ "alpha-entry");
+ float_to_entry (GTK_ENTRY (state->alpha_entry), 0.05);
+ g_signal_connect_after (G_OBJECT (state->alpha_entry),
+ "changed",
+ G_CALLBACK (normality_tool_update_sensitivity_cb), state);
+ gnumeric_editable_enters (GTK_WINDOW (state->base.dialog),
+ GTK_WIDGET (state->alpha_entry));
+
+ gnm_dao_set_put (GNM_DAO (state->base.gdao), TRUE, TRUE);
+ normality_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 fbc2cce..5fa9adf 100644
--- a/src/dialogs/dialogs.h
+++ b/src/dialogs/dialogs.h
@@ -91,6 +91,7 @@ int dialog_anova_two_factor_tool (WBCGtk *wbcg, Sheet *sheet);
int dialog_histogram_tool (WBCGtk *wbcg, Sheet *sheet);
int dialog_frequency_tool (WBCGtk *wbcg, Sheet *sheet);
int dialog_kaplan_meier_tool (WBCGtk *wbcg, Sheet *sheet);
+int dialog_normality_tool (WBCGtk *wbcg, Sheet *sheet);
int dialog_chi_square_tool (WBCGtk *wbcg, Sheet *sheet, gboolean independence);
typedef enum {
diff --git a/src/dialogs/help.h b/src/dialogs/help.h
index d4f15e1..856329b 100644
--- a/src/dialogs/help.h
+++ b/src/dialogs/help.h
@@ -155,6 +155,9 @@
/* dialog-analysis-tool-kaplan-meier.c */
#define GNUMERIC_HELP_LINK_KAPLAN_MEIER "sect-analysis-statistical"
+/* dialog-analysis-tool-normality.c */
+#define GNUMERIC_HELP_LINK_NORMALITY "sect-analysis-statistical"
+
/* dialog-consolidate.c */
#define GNUMERIC_HELP_LINK_CONSOLIDATE ""
diff --git a/src/dialogs/normality-tests.glade b/src/dialogs/normality-tests.glade
new file mode 100644
index 0000000..f02654c
--- /dev/null
+++ b/src/dialogs/normality-tests.glade
@@ -0,0 +1,347 @@
+<?xml version="1.0"?>
+<glade-interface>
+ <!-- interface-requires gtk+ 2.6 -->
+ <!-- interface-naming-policy toplevel-contextual -->
+ <widget class="GtkDialog" id="Normality-Tests">
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Normality Tests</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="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child>
+ <widget class="GtkNotebook" id="notebook1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="border_width">5</property>
+ <child>
+ <widget class="GtkTable" id="input-table">
+ <property name="visible">True</property>
+ <property name="border_width">12</property>
+ <property name="n_rows">5</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="label" translatable="yes">_Input 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="label2">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Grouped by:</property>
+ <property name="justify">center</property>
+ <accessibility>
+ <atkrelation type="label-for" target="grouped_by_col"/>
+ </accessibility>
+ </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">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="vbox2">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkRadioButton" id="grouped_by_col">
+ <property name="label" translatable="yes">_Columns</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="active">True</property>
+ <property name="draw_indicator">True</property>
+ <accessibility>
+ <atkrelation type="labelled-by" target="label2"/>
+ </accessibility>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</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">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkRadioButton" id="grouped_by_row">
+ <property name="label" translatable="yes">_Rows</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>
+ <property name="group">grouped_by_col</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <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>
+ <widget class="GtkRadioButton" id="grouped_by_area">
+ <property name="label" translatable="yes">_Areas</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>
+ <property name="group">grouped_by_col</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Input</property>
+ </widget>
+ <packing>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkTable" id="table2">
+ <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="label3">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Alpha:</property>
+ <property name="use_underline">True</property>
+ <property name="justify">right</property>
+ <property name="mnemonic_widget">alpha-entry</property>
+ </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="GtkSpinButton" id="alpha-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</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>
+ <child>
+ <widget class="GtkRadioButton" id="andersondarling">
+ <property name="label" translatable="yes">Anderson-Darling Test</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="right_attach">2</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Test</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="label7">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Output</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 cee5e83..69023fb 100644
--- a/src/tools/ChangeLog
+++ b/src/tools/ChangeLog
@@ -1,3 +1,12 @@
+2009-11-21 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * analysis-normality.c: new
+ * analysis-normality.h: new
+ * Makefile.am: add analysis-normality.[ch]
+ * analysis-exp-smoothing.c: fix comment
+ * analysis-tools.h (analysis_tools_write_label): new
+ * analysis-tools.c (analysis_tools_write_label): make non-static
+
2009-11-17 Morten Welinder <terra gnome org>
* gnm-solver.c (cb_child_exit): When child exits, close the GPid.
diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am
index 327c4c6..663a2af 100644
--- a/src/tools/Makefile.am
+++ b/src/tools/Makefile.am
@@ -27,6 +27,8 @@ libtools_la_SOURCES = \
analysis-histogram.h \
analysis-kaplan-meier.c \
analysis-kaplan-meier.h \
+ analysis-normality.c \
+ analysis-normality.h \
analysis-tools.c \
analysis-tools.h \
random-generator.c \
diff --git a/src/tools/analysis-exp-smoothing.c b/src/tools/analysis-exp-smoothing.c
index 3a8f22e..73dc13c 100644
--- a/src/tools/analysis-exp-smoothing.c
+++ b/src/tools/analysis-exp-smoothing.c
@@ -1,6 +1,6 @@
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * analysis-histogram.c:
+ * analysis-exp-smoothing.c:
*
* This is a complete reimplementation of the exponential smoothing tool in tool in 2008
*
diff --git a/src/tools/analysis-normality.c b/src/tools/analysis-normality.c
new file mode 100644
index 0000000..bcc03ae
--- /dev/null
+++ b/src/tools/analysis-normality.c
@@ -0,0 +1,153 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * analysis-normality.c:
+ *
+ *
+ * Author:
+ * Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ * (C) Copyright 2009 by Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gnumeric-config.h>
+#include <glib/gi18n-lib.h>
+#include "gnumeric.h"
+#include "analysis-normality.h"
+#include "analysis-tools.h"
+#include "value.h"
+#include "ranges.h"
+#include "expr.h"
+#include "func.h"
+#include "numbers.h"
+#include "sheet-object-graph.h"
+#include "graph.h"
+#include <goffice/goffice.h>
+#include "sheet.h"
+
+
+static gboolean
+analysis_tool_normality_engine_run (data_analysis_output_t *dao,
+ analysis_tools_data_normality_t *info)
+{
+ guint col;
+ GSList *data = info->base.input;
+ GnmFunc *fd;
+ GnmFunc *fd_if;
+
+ char const *fdname;
+ char const *testname;
+ char const *n_comment;
+
+ switch (info->type) {
+ case 'a':
+ default:
+ fdname = "ADTEST";
+ testname = N_("Anderson-Darling Test");
+ n_comment = N_("For the Anderson-Darling Test\n"
+ "the size the sample must be at\n"
+ "least 8.");
+ }
+
+ fd = gnm_func_lookup_or_add_placeholder
+ (fdname, dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd);
+ fd_if = gnm_func_lookup_or_add_placeholder
+ ("IF", dao->sheet ? dao->sheet->workbook : NULL, FALSE);
+ gnm_func_ref (fd_if);
+
+ dao_set_italic (dao, 0, 0, 0, 5);
+ dao_set_cell (dao, 0, 0, _(testname));
+
+ /* xgettext:
+ * Note to translators: in the following string and others like it,
+ * the "/" is a separator character that can be changed to anything
+ * if the translation needs the slash; just use, say, "|" instead.
+ *
+ * The items are bundled like this to increase translation context.
+ */
+ set_cell_text_col (dao, 0, 1, _("/Alpha"
+ "/p-Value"
+ "/Statistic"
+ "/N"
+ "/Conclusion"));
+
+ dao_set_cell_comment (dao, 0, 4, _(n_comment));
+
+ for (col = 1; data != NULL; data = data->next, col++) {
+ GnmValue *val_org = value_dup (data->data);
+
+ /* Note that analysis_tools_write_label may modify val_org */
+ dao_set_italic (dao, col, 0, col, 0);
+ analysis_tools_write_label (val_org, dao, &info->base,
+ col, 0, col);
+ if (col == 1)
+ dao_set_cell_float (dao, col, 1, info->alpha);
+ else
+ dao_set_cell_expr (dao, col, 1,
+ make_cellref (1 - col, 0));
+
+ dao_set_array_expr (dao, col, 2, 1, 3,
+ gnm_expr_new_funcall1 (fd, gnm_expr_new_constant (val_org)));
+ dao_set_cell_expr (dao, col, 5,
+ gnm_expr_new_funcall3
+ (fd_if, gnm_expr_new_binary
+ (make_cellref (0, -4),
+ GNM_EXPR_OP_GTE,
+ make_cellref (0, -3)),
+ gnm_expr_new_constant (value_new_string (_("Not normal"))),
+ gnm_expr_new_constant (value_new_string (_("Possibly normal")))));
+ }
+
+ gnm_func_unref (fd);
+ gnm_func_unref (fd_if);
+
+ dao_autofit_columns (dao);
+ dao_redraw_respan (dao);
+ return 0;
+}
+
+gboolean
+analysis_tool_normality_engine (data_analysis_output_t *dao, gpointer specs,
+ analysis_tool_engine_t selector, gpointer result)
+{
+ analysis_tools_data_normality_t *info = specs;
+
+ switch (selector) {
+ case TOOL_ENGINE_UPDATE_DESCRIPTOR:
+ return (dao_command_descriptor (dao, _("Normality Test (%s)"), result)
+ == NULL);
+ case TOOL_ENGINE_UPDATE_DAO:
+ prepare_input_range (&info->base.input, info->base.group_by);
+ dao_adjust (dao, 1 + g_slist_length (info->base.input), 6);
+ 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, _("Normality Test"));
+ return FALSE;
+ case TOOL_ENGINE_FORMAT_OUTPUT_RANGE:
+ return dao_format_output (dao, _("Normality Test"));
+ case TOOL_ENGINE_PERFORM_CALC:
+ default:
+ return analysis_tool_normality_engine_run (dao, specs);
+ }
+ return TRUE; /* We shouldn't get here */
+}
+
diff --git a/src/tools/analysis-normality.h b/src/tools/analysis-normality.h
new file mode 100644
index 0000000..fdc3e78
--- /dev/null
+++ b/src/tools/analysis-normality.h
@@ -0,0 +1,48 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * analysis-normality.h:
+ *
+ * Author:
+ * Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ * (C) Copyright 2009 by Andreas J. Guelzow <aguelzow pyrshep ca>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#ifndef ANALYSIS_NORMALITY_H
+#define ANALYSIS_NORMALITY_H
+
+#include "gnumeric.h"
+#include "numbers.h"
+#include "dao.h"
+#include "tools.h"
+#include "analysis-tools.h"
+
+/**************** Normality Tests ***************/
+
+typedef struct {
+ analysis_tools_data_generic_t base;
+ gnm_float alpha;
+ char type; /* 'A'= Anderson-Darling */
+} analysis_tools_data_normality_t;
+
+gboolean analysis_tool_normality_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 14a83a9..b545920 100644
--- a/src/tools/analysis-tools.c
+++ b/src/tools/analysis-tools.c
@@ -166,7 +166,7 @@ analysis_tools_remove_label (GnmValue *val,
*
*/
-static void
+void
analysis_tools_write_label (GnmValue *val, data_analysis_output_t *dao,
analysis_tools_data_generic_t *info,
int x, int y, int i)
diff --git a/src/tools/analysis-tools.h b/src/tools/analysis-tools.h
index 26658c4..555f4c1 100644
--- a/src/tools/analysis-tools.h
+++ b/src/tools/analysis-tools.h
@@ -209,7 +209,9 @@ 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 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 97344aa..5f70238 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -879,6 +879,7 @@ static GNM_ACTION_DEF (cb_tools_fourier) { dialog_fourier_tool (wbcg, wbcg_cur_s
static GNM_ACTION_DEF (cb_tools_frequency) { dialog_frequency_tool (wbcg, wbcg_cur_sheet (wbcg)); }
static GNM_ACTION_DEF (cb_tools_histogram) { dialog_histogram_tool (wbcg, wbcg_cur_sheet (wbcg)); }
static GNM_ACTION_DEF (cb_tools_kaplan_meier) { dialog_kaplan_meier_tool (wbcg, wbcg_cur_sheet (wbcg)); }
+static GNM_ACTION_DEF (cb_tools_normality_tests){ dialog_normality_tool (wbcg, wbcg_cur_sheet (wbcg)); }
static GNM_ACTION_DEF (cb_tools_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)); }
@@ -2136,6 +2137,9 @@ static GtkActionEntry const actions[] = {
{ "ToolsKaplanMeier", NULL, N_("_Kaplan-Meier Estimates..."),
NULL, N_("Creation of Kaplan-Meier Survival Curves"),
G_CALLBACK (cb_tools_kaplan_meier) },
+ { "ToolsNormalityTests", NULL, N_("_Normality Tests..."),
+ NULL, N_("Testing a sample for normality"),
+ G_CALLBACK (cb_tools_normality_tests) },
/* Data */
{ "DataSort", GTK_STOCK_SORT_ASCENDING, N_("_Sort..."),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]