gnumeric r16828 - in trunk: . src/dialogs src/tools
- From: guelzow svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16828 - in trunk: . src/dialogs src/tools
- Date: Fri, 26 Sep 2008 05:55:58 +0000 (UTC)
Author: guelzow
Date: Fri Sep 26 05:55:58 2008
New Revision: 16828
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16828&view=rev
Log:
2008-09-26 Andreas J. Guelzow <aguelzow pyrshep ca>
* analysis-tools.h (analysis_tools_data_exponential_smoothing_t):
add field
(exponential_smoothing_type_t): add items
* analysis-tools.c (analysis_tool_exponential_smoothing_engine_run):
add handling of Holt's trend corrected exponential smoothing
(analysis_tool_exponential_smoothing_engine): adjust size
2008-09-26 Andreas J. Guelzow <aguelzow pyrshep ca>
* exp-smoothing.glade: aded controls for Holt's
* dialog-analysis-tools.c (exp_smoothing_group):
added more buttons
(ExpSmoothToolState): added more fields
(exp_smoothing_tool_ok_clicked_cb): retrieve info from
additional fields
(exp_smoothing_tool_update_sensitivity_cb): check for
additional info.
(exp_smoothing_ses_cb): new
(exp_smoothing_des_cb): new
(exp_smoothing_tes_cb): new
(dialog_exp_smoothing_tool): setup new controls
Modified:
trunk/NEWS
trunk/src/dialogs/ChangeLog
trunk/src/dialogs/dialog-analysis-tools.c
trunk/src/dialogs/exp-smoothing.glade
trunk/src/tools/ChangeLog
trunk/src/tools/analysis-tools.c
trunk/src/tools/analysis-tools.h
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Fri Sep 26 05:55:58 2008
@@ -19,6 +19,7 @@
* Add weighted and cumulative moving averages.
* Add Spencer's 15-point moving average.
* Fix and improve exponential smoothing tool. [#553267]
+ * Added Holt's trend corrected exponential smoothing. [#385467]
Jean:
* Fix printing of rotated text. [#539734]
Modified: trunk/src/dialogs/dialog-analysis-tools.c
==============================================================================
--- trunk/src/dialogs/dialog-analysis-tools.c (original)
+++ trunk/src/dialogs/dialog-analysis-tools.c Fri Sep 26 05:55:58 2008
@@ -134,6 +134,9 @@
static char const * const exp_smoothing_group[] = {
"ses-h-button",
"ses-r-button",
+ "des-button",
+ "ates-button",
+ "mtes-button",
NULL
};
@@ -211,11 +214,18 @@
typedef struct {
GenericToolState base;
GtkWidget *damping_fact_entry;
+ GtkWidget *g_damping_fact_entry;
+ GtkWidget *s_damping_fact_entry;
GtkWidget *show_std_errors;
GtkWidget *n_button;
GtkWidget *nm1_button;
GtkWidget *nm2_button;
GtkWidget *graph_button;
+ GtkWidget *ses_h_button;
+ GtkWidget *ses_r_button;
+ GtkWidget *des_button;
+ GtkWidget *ates_button;
+ GtkWidget *mtes_button;
} ExpSmoothToolState;
typedef struct {
@@ -2311,13 +2321,19 @@
data->base.labels = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
err = entry_to_float (GTK_ENTRY (state->damping_fact_entry), &data->damp_fact, TRUE);
-
- data->std_error_flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (state->show_std_errors));
- data->show_graph = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (state->graph_button));
+ err = entry_to_float (GTK_ENTRY (state->g_damping_fact_entry),
+ &data->g_damp_fact, TRUE);
+ err = entry_to_float (GTK_ENTRY (state->s_damping_fact_entry),
+ &data->s_damp_fact, TRUE);
+
+ data->std_error_flag = gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (state->show_std_errors));
+ data->show_graph = gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (state->graph_button));
data->df = gnumeric_glade_group_value (state->base.gui, n_group);
data->es_type = gnumeric_glade_group_value (state->base.gui, exp_smoothing_group);
-
+
if (!cmd_analysis_tool (WORKBOOK_CONTROL (state->base.wbcg), state->base.sheet,
dao, data, analysis_tool_exponential_smoothing_engine))
gtk_widget_destroy (state->base.dialog);
@@ -2352,12 +2368,41 @@
} else
range_list_destroy (input_range);
- err = entry_to_float (GTK_ENTRY (state->damping_fact_entry), &damp_fact, FALSE);
- if (err!= 0 || damp_fact < 0 || damp_fact > 1) {
- gtk_label_set_text (GTK_LABEL (state->base.warning),
- _("The given damping factor is invalid."));
+ switch (gnumeric_glade_group_value (state->base.gui, exp_smoothing_group)) {
+ case moving_average_type_mtes:
+ case moving_average_type_ates:
+ err = entry_to_float (GTK_ENTRY (state->s_damping_fact_entry),
+ &damp_fact, FALSE);
+ if (err!= 0 || damp_fact < 0 || damp_fact > 1) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning),
+ _("The given seasonal damping "
+ "factor is invalid."));
+ gtk_widget_set_sensitive (state->base.ok_button, FALSE);
+ return;
+ }
+ /* no break */
+ case moving_average_type_des:
+ err = entry_to_float (GTK_ENTRY (state->g_damping_fact_entry),
+ &damp_fact, FALSE);
+ if (err!= 0 || damp_fact < 0 || damp_fact > 1) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning),
+ _("The given growth"
+ "damping factor is invalid."));
+ gtk_widget_set_sensitive (state->base.ok_button, FALSE);
+ return;
+ }
+ /* no break */
+ case moving_average_type_ses_r:
+ case moving_average_type_ses_h:
+ err = entry_to_float (GTK_ENTRY (state->damping_fact_entry),
+ &damp_fact, FALSE);
+ if (err!= 0 || damp_fact < 0 || damp_fact > 1) {
+ gtk_label_set_text (GTK_LABEL (state->base.warning),
+ _("The given damping factor is invalid."));
gtk_widget_set_sensitive (state->base.ok_button, FALSE);
return;
+ }
+ break;
}
if (!gnm_dao_is_ready (GNM_DAO (state->base.gdao))) {
@@ -2379,6 +2424,51 @@
}
+static void
+exp_smoothing_ses_cb (GtkToggleButton *togglebutton, gpointer user_data)
+{
+ ExpSmoothToolState *state = (ExpSmoothToolState *)user_data;
+
+ if (!gtk_toggle_button_get_active (togglebutton))
+ return;
+
+ gtk_widget_set_sensitive (state->g_damping_fact_entry, FALSE);
+ gtk_widget_set_sensitive (state->s_damping_fact_entry, FALSE);
+ gtk_widget_set_sensitive (state->n_button, TRUE);
+ gtk_widget_set_sensitive (state->nm1_button, TRUE);
+ gtk_widget_set_sensitive (state->nm2_button, TRUE);
+ gtk_widget_set_sensitive (state->show_std_errors, TRUE);
+}
+
+static void
+exp_smoothing_des_cb (GtkToggleButton *togglebutton, gpointer user_data)
+{
+ ExpSmoothToolState *state = (ExpSmoothToolState *)user_data;
+
+ if (!gtk_toggle_button_get_active (togglebutton))
+ return;
+
+ gtk_widget_set_sensitive (state->g_damping_fact_entry, TRUE);
+ gtk_widget_set_sensitive (state->s_damping_fact_entry, FALSE);
+ gtk_widget_set_sensitive (state->n_button, FALSE);
+ gtk_widget_set_sensitive (state->nm1_button, FALSE);
+ gtk_widget_set_sensitive (state->nm2_button, FALSE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->show_std_errors), FALSE);
+ gtk_widget_set_sensitive (state->show_std_errors, FALSE);
+}
+
+static void
+exp_smoothing_tes_cb (GtkToggleButton *togglebutton, gpointer user_data)
+{
+ ExpSmoothToolState *state = (ExpSmoothToolState *)user_data;
+
+ if (!gtk_toggle_button_get_active (togglebutton))
+ return;
+
+ gtk_widget_set_sensitive (state->g_damping_fact_entry, TRUE);
+ gtk_widget_set_sensitive (state->s_damping_fact_entry, TRUE);
+}
+
/**
* dialog_exp_smoothing_tool:
* @wbcg:
@@ -2418,6 +2508,12 @@
state->damping_fact_entry = glade_xml_get_widget (state->base.gui,
"damping-fact-spin");
float_to_entry (GTK_ENTRY (state->damping_fact_entry), 0.2);
+ state->g_damping_fact_entry = glade_xml_get_widget (state->base.gui,
+ "g-damping-fact-spin");
+ float_to_entry (GTK_ENTRY (state->g_damping_fact_entry), 0.2);
+ state->s_damping_fact_entry = glade_xml_get_widget (state->base.gui,
+ "s-damping-fact-spin");
+ float_to_entry (GTK_ENTRY (state->s_damping_fact_entry), 0.2);
state->n_button = glade_xml_get_widget (state->base.gui, "n-button");
state->nm1_button = glade_xml_get_widget (state->base.gui, "nm1-button");
@@ -2425,6 +2521,12 @@
state->show_std_errors = glade_xml_get_widget (state->base.gui, "std-errors-button");
state->graph_button = glade_xml_get_widget (state->base.gui, "graph-check");
+
+ state->ses_h_button = glade_xml_get_widget (state->base.gui, "ses-h-button");
+ state->ses_r_button = glade_xml_get_widget (state->base.gui, "ses-r-button");
+ state->des_button = glade_xml_get_widget (state->base.gui, "des-button");
+ state->ates_button = glade_xml_get_widget (state->base.gui, "ates-button");
+ state->mtes_button = glade_xml_get_widget (state->base.gui, "mtes-button");
g_signal_connect_after (G_OBJECT (state->n_button),
"toggled",
@@ -2438,12 +2540,38 @@
g_signal_connect_after (G_OBJECT (state->damping_fact_entry),
"changed",
G_CALLBACK (exp_smoothing_tool_update_sensitivity_cb), state);
+
+ g_signal_connect_after (G_OBJECT (state->ses_h_button),
+ "toggled",
+ G_CALLBACK (exp_smoothing_ses_cb), state);
+ g_signal_connect_after (G_OBJECT (state->ses_r_button),
+ "toggled",
+ G_CALLBACK (exp_smoothing_ses_cb), state);
+ g_signal_connect_after (G_OBJECT (state->des_button),
+ "toggled",
+ G_CALLBACK (exp_smoothing_des_cb), state);
+ g_signal_connect_after (G_OBJECT (state->ates_button),
+ "toggled",
+ G_CALLBACK (exp_smoothing_tes_cb), state);
+ g_signal_connect_after (G_OBJECT (state->mtes_button),
+ "toggled",
+ G_CALLBACK (exp_smoothing_tes_cb), state);
+
gnumeric_editable_enters (GTK_WINDOW (state->base.dialog),
GTK_WIDGET (state->damping_fact_entry));
+ gnumeric_editable_enters (GTK_WINDOW (state->base.dialog),
+ GTK_WIDGET (state->g_damping_fact_entry));
+ gnumeric_editable_enters (GTK_WINDOW (state->base.dialog),
+ GTK_WIDGET (state->s_damping_fact_entry));
gnm_dao_set_put (GNM_DAO (state->base.gdao), TRUE, TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->ses_h_button), TRUE);
+ exp_smoothing_ses_cb (state->ses_h_button, state);
exp_smoothing_tool_update_sensitivity_cb (NULL, state);
tool_load_selection ((GenericToolState *)state, TRUE);
+
+ gtk_widget_set_sensitive (state->ates_button, FALSE);
+ gtk_widget_set_sensitive (state->mtes_button, FALSE);
return 0;
}
Modified: trunk/src/dialogs/exp-smoothing.glade
==============================================================================
--- trunk/src/dialogs/exp-smoothing.glade (original)
+++ trunk/src/dialogs/exp-smoothing.glade Fri Sep 26 05:55:58 2008
@@ -34,6 +34,48 @@
<placeholder/>
</child>
<child>
+ <widget class="GtkCheckButton" id="labels_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Labels</property>
+ <property name="use_underline">True</property>
+ <property name="response_id">0</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <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="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Grouped by:</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="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>
+ </widget>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
@@ -71,48 +113,6 @@
<property name="y_options"></property>
</packing>
</child>
- <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>
- </widget>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Grouped by:</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="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">_Labels</property>
- <property name="use_underline">True</property>
- <property name="response_id">0</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <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>
</widget>
</child>
<child>
@@ -128,20 +128,51 @@
<widget class="GtkTable" id="table4">
<property name="visible">True</property>
<property name="border_width">12</property>
- <property name="n_rows">4</property>
+ <property name="n_rows">5</property>
<property name="n_columns">1</property>
<child>
- <placeholder/>
+ <widget class="GtkRadioButton" id="mtes-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Multiplicative Holt-Winters exponential smoothing</property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">ses-h-button</property>
+ </widget>
+ <packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ </packing>
</child>
<child>
- <widget class="GtkRadioButton" id="ses-h-button">
+ <widget class="GtkRadioButton" id="ates-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Simple exponential smoothing (Hunter, 1986)</property>
+ <property name="label" translatable="yes">Additive Holt-Winters exponential smoothing</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
+ <property name="group">ses-h-button</property>
</widget>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkRadioButton" id="des-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Holt's trend corrected exponential smoothing</property>
+ <property name="response_id">0</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">ses-h-button</property>
+ </widget>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
</child>
<child>
<widget class="GtkRadioButton" id="ses-r-button">
@@ -158,19 +189,14 @@
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="wma-button">
+ <widget class="GtkRadioButton" id="ses-h-button">
<property name="visible">True</property>
- <property name="sensitive">False</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Double exponential smoothing</property>
+ <property name="label" translatable="yes">Simple exponential smoothing (Hunter, 1986)</property>
<property name="response_id">0</property>
+ <property name="active">True</property>
<property name="draw_indicator">True</property>
- <property name="group">ses-h-button</property>
</widget>
- <packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- </packing>
</child>
</widget>
<packing>
@@ -198,17 +224,65 @@
<widget class="GtkTable" id="table3">
<property name="visible">True</property>
<property name="border_width">12</property>
- <property name="n_rows">1</property>
+ <property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<child>
- <widget class="GtkLabel" id="label3">
+ <widget class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Seasonal damping factor (Î):</property>
+ <property name="use_underline">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>
+ <widget class="GtkSpinButton" id="s-damping-fact-spin">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="xalign">1</property>
+ <property name="adjustment">0.20000000000000001 0 1 0.01 0.10000000000000001 0.10000000000000001</property>
+ <property name="digits">3</property>
+ <property name="numeric">True</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>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkSpinButton" id="g-damping-fact-spin">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="xalign">1</property>
+ <property name="adjustment">0.20000000000000001 0 1 0.01 0.10000000000000001 0.10000000000000001</property>
+ <property name="digits">3</property>
+ <property name="numeric">True</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>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">_Damping Factor (Î):</property>
+ <property name="label" translatable="yes">Growth damping factor (Î):</property>
<property name="use_underline">True</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>
@@ -227,6 +301,18 @@
<property name="right_attach">2</property>
</packing>
</child>
+ <child>
+ <widget class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Damping factor (Î):</property>
+ <property name="use_underline">True</property>
+ </widget>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -251,28 +337,35 @@
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
- <widget class="GtkCheckButton" id="std-errors-button">
+ <widget class="GtkRadioButton" id="nm2-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">_Standard errors</property>
- <property name="use_underline">True</property>
+ <property name="label" translatable="yes">nâ2</property>
<property name="response_id">0</property>
+ <property name="active">True</property>
<property name="draw_indicator">True</property>
+ <property name="group">n-button</property>
</widget>
<packing>
+ <property name="left_attach">3</property>
<property name="right_attach">4</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label7">
+ <widget class="GtkRadioButton" id="nm1-button">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Denominator:</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">nâ1</property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">n-button</property>
</widget>
<packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
@@ -298,18 +391,12 @@
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="nm1-button">
+ <widget class="GtkLabel" id="label7">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">nâ1</property>
- <property name="response_id">0</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- <property name="group">n-button</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Denominator:</property>
</widget>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
@@ -317,20 +404,19 @@
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="nm2-button">
+ <widget class="GtkCheckButton" id="std-errors-button">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">nâ2</property>
+ <property name="label" translatable="yes">_Standard errors</property>
+ <property name="use_underline">True</property>
<property name="response_id">0</property>
- <property name="active">True</property>
<property name="draw_indicator">True</property>
- <property name="group">n-button</property>
</widget>
<packing>
- <property name="left_attach">3</property>
<property name="right_attach">4</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
</packing>
</child>
</widget>
@@ -350,12 +436,6 @@
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<widget class="GtkTable" id="table5">
<property name="visible">True</property>
<property name="border_width">12</property>
@@ -374,7 +454,7 @@
</widget>
<packing>
<property name="expand">False</property>
- <property name="position">6</property>
+ <property name="position">4</property>
</packing>
</child>
</widget>
Modified: trunk/src/tools/analysis-tools.c
==============================================================================
--- trunk/src/tools/analysis-tools.c (original)
+++ trunk/src/tools/analysis-tools.c Fri Sep 26 05:55:58 2008
@@ -3826,7 +3826,9 @@
GnmFunc *fd_offset;
GnmFunc *fd_sqrt = NULL;
GnmFunc *fd_sumxmy2 = NULL;
- GnmExpr const *expr_alpha;
+ GnmFunc *fd_linest = NULL;
+ GnmExpr const *expr_alpha = NULL;
+ GnmExpr const *expr_gamma = NULL;
if (info->std_error_flag) {
fd_sqrt = gnm_func_lookup ("SQRT", NULL);
@@ -3834,6 +3836,11 @@
fd_sumxmy2 = gnm_func_lookup ("SUMXMY2", NULL);
gnm_func_ref (fd_sumxmy2);
}
+ if (info->es_type == moving_average_type_des) {
+ fd_linest = gnm_func_lookup ("LINEST", NULL);
+ gnm_func_ref (fd_linest);
+ }
+
fd_index = gnm_func_lookup ("INDEX", NULL);
gnm_func_ref (fd_index);
fd_offset = gnm_func_lookup ("OFFSET", NULL);
@@ -3854,9 +3861,17 @@
dao_set_italic (dao, 0, 0, 0, 0);
dao_set_cell (dao, 0, 0, _("Exponential Smoothing"));
- dao_set_format (dao, 0, 1, 0, 1, _("\"\xce\xbb =\" * 0.000"));
+ dao_set_format (dao, 0, 1, 0, 1, _("\"\xce\xb1 =\" * 0.000"));
dao_set_cell_expr (dao, 0, 1, gnm_expr_new_constant (value_new_float (info->damp_fact)));
expr_alpha = dao_get_cellref (dao, 0, 1);
+
+ if (info->es_type == moving_average_type_des || info->es_type == moving_average_type_ates
+ || info->es_type == moving_average_type_mtes) {
+ dao_set_format (dao, 1, 1, 1, 1, _("\"\xce\xb3 =\" * 0.000"));
+ dao_set_cell_expr (dao, 1, 1, gnm_expr_new_constant (value_new_float (info->g_damp_fact)));
+ expr_gamma = dao_get_cellref (dao, 1, 1);
+ }
+
dao->offset_row = 2;
for (l = info->base.input, source = 1; l; l = l->next, col++, source++) {
@@ -3917,6 +3932,10 @@
if (plot != NULL) {
GogSeries *series;
+ int plot_start = 1;
+
+ if (info->es_type = moving_average_type_des)
+ plot_start++;
series = gog_plot_new_series (plot);
gog_series_set_dim (series, 1,
@@ -3926,45 +3945,110 @@
series = gog_plot_new_series (plot);
gog_series_set_dim (series, 1,
- dao_go_data_vector (dao, col, 1, col, height),
+ dao_go_data_vector (dao, col, plot_start , col, plot_start + height - 1),
NULL);
}
-
- if (info->es_type == moving_average_type_ses_r)
- {
- /* F(t+1) = F(t) + (1 - damp_fact) * ( A(t+1) - F(t) ) */
- (*mover) = 2;
- base = 1;
- se_adj = -1;
- } else {
- /* F(t+1) = F(t) + (1 - damp_fact) * ( A(t) - F(t) ) */
- (*mover) = 1;
- base = 1;
- se_adj = 0;
- }
+ switch (info->es_type) {
+ case moving_average_type_des:
+ {
+ GnmExpr const *expr_linest;
- dao_set_cell_expr (dao, col, 1,
- gnm_expr_new_funcall1 (fd_index,
- gnm_expr_copy (expr_input)));
- for (row = 2; row <= height; row++, (*mover)++) {
- GnmExpr const *A;
- GnmExpr const *F;
+ x = 1;
+ y = 1;
+ *mover = 5;
+ expr_linest = gnm_expr_new_funcall1
+ (fd_linest,
+ analysis_tool_moving_average_funcall5 (fd_offset, expr_input , 0, 0, y, x));
+ dao_set_cell_expr (dao, col, 1,
+ gnm_expr_new_funcall3 (fd_index,
+ gnm_expr_copy (expr_linest),
+ gnm_expr_new_constant (value_new_int (1)),
+ gnm_expr_new_constant (value_new_int (2))));
+ dao_set_cell_expr (dao, col + 1, 1,
+ gnm_expr_new_funcall3 (fd_index,
+ expr_linest,
+ gnm_expr_new_constant (value_new_int (1)),
+ gnm_expr_new_constant (value_new_int (1))));
+
+ x = 1;
+ y = 1;
+ *mover = 1;
+ for (row = 1; row <= height; row++, (*mover)++) {
+ GnmExpr const *LB;
+ GnmExpr const *A;
+ GnmExpr const *LL;
+ GnmExpr const *B;
+ A = gnm_expr_new_binary (gnm_expr_copy (expr_alpha),
+ GNM_EXPR_OP_MULT,
+ gnm_expr_new_funcall3
+ (fd_index,
+ gnm_expr_copy (expr_input),
+ gnm_expr_new_constant(value_new_int(y)),
+ gnm_expr_new_constant(value_new_int(x))));
+ LB = gnm_expr_new_binary (gnm_expr_new_binary (gnm_expr_new_constant
+ (value_new_int (1)),
+ GNM_EXPR_OP_SUB,
+ gnm_expr_copy (expr_alpha)),
+ GNM_EXPR_OP_MULT,
+ gnm_expr_new_binary (make_cellref (0, -1),
+ GNM_EXPR_OP_ADD,
+ make_cellref (1, -1)));
+ dao_set_cell_expr (dao, col, row + 1, gnm_expr_new_binary (A, GNM_EXPR_OP_ADD, LB));
+
+ LL = gnm_expr_new_binary (gnm_expr_copy (expr_gamma),
+ GNM_EXPR_OP_MULT,
+ gnm_expr_new_binary (make_cellref (-1, 0),
+ GNM_EXPR_OP_SUB,
+ make_cellref (-1, -1)));
+ B = gnm_expr_new_binary (gnm_expr_new_binary (gnm_expr_new_constant
+ (value_new_int (1)),
+ GNM_EXPR_OP_SUB,
+ gnm_expr_copy (expr_gamma)),
+ GNM_EXPR_OP_MULT,
+ make_cellref (0, -1));
+ dao_set_cell_expr (dao, col + 1, row + 1, gnm_expr_new_binary (LL, GNM_EXPR_OP_ADD, B));
+ }
+ col++;
+ }
+ break;
+ default:
+ if (info->es_type == moving_average_type_ses_r)
+ {
+ /* F(t+1) = F(t) + damp_fact * ( A(t+1) - F(t) ) */
+ (*mover) = 2;
+ base = 1;
+ se_adj = -1;
+ } else {
+ /* F(t+1) = F(t) + damp_fact * ( A(t) - F(t) ) */
+ (*mover) = 1;
+ base = 1;
+ se_adj = 0;
+ }
- A = gnm_expr_new_binary (gnm_expr_new_binary (gnm_expr_new_constant
- (value_new_int (1)),
- GNM_EXPR_OP_SUB,
- gnm_expr_copy (expr_alpha)),
- GNM_EXPR_OP_MULT,
- gnm_expr_new_funcall3
- (fd_index,
- gnm_expr_copy (expr_input),
- gnm_expr_new_constant(value_new_int(y)),
- gnm_expr_new_constant(value_new_int(x))));
- F = gnm_expr_new_binary (gnm_expr_copy (expr_alpha),
- GNM_EXPR_OP_MULT,
- make_cellref (0, -1));
- dao_set_cell_expr (dao, col, row, gnm_expr_new_binary (A, GNM_EXPR_OP_ADD, F));
+ dao_set_cell_expr (dao, col, 1,
+ gnm_expr_new_funcall1 (fd_index,
+ gnm_expr_copy (expr_input)));
+ for (row = 2; row <= height; row++, (*mover)++) {
+ GnmExpr const *A;
+ GnmExpr const *F;
+
+ A = gnm_expr_new_binary (gnm_expr_copy (expr_alpha),
+ GNM_EXPR_OP_MULT,
+ gnm_expr_new_funcall3
+ (fd_index,
+ gnm_expr_copy (expr_input),
+ gnm_expr_new_constant(value_new_int(y)),
+ gnm_expr_new_constant(value_new_int(x))));
+ F = gnm_expr_new_binary (gnm_expr_new_binary (gnm_expr_new_constant
+ (value_new_int (1)),
+ GNM_EXPR_OP_SUB,
+ gnm_expr_copy (expr_alpha)),
+ GNM_EXPR_OP_MULT,
+ make_cellref (0, -1));
+ dao_set_cell_expr (dao, col, row, gnm_expr_new_binary (A, GNM_EXPR_OP_ADD, F));
+ }
+ break;
}
if (info->std_error_flag) {
@@ -4009,10 +4093,14 @@
dao_set_sheet_object (dao, 0, 1, so);
gnm_expr_free (expr_alpha);
+ if (expr_gamma)
+ gnm_expr_free (expr_gamma);
if (fd_sqrt != NULL)
gnm_func_unref (fd_sqrt);
if (fd_sumxmy2 != NULL)
gnm_func_unref (fd_sumxmy2);
+ if (fd_linest != NULL)
+ gnm_func_unref (fd_linest);
gnm_func_unref (fd_offset);
gnm_func_unref (fd_index);
@@ -4028,6 +4116,7 @@
gpointer result)
{
analysis_tools_data_exponential_smoothing_t *info = specs;
+ int n = 0, m;
switch (selector) {
case TOOL_ENGINE_UPDATE_DESCRIPTOR:
@@ -4035,9 +4124,16 @@
== NULL);
case TOOL_ENGINE_UPDATE_DAO:
prepare_input_range (&info->base.input, info->base.group_by);
- dao_adjust (dao, (info->std_error_flag ? 2 : 1) *
- g_slist_length (info->base.input),
- 3 + analysis_tool_calc_length (specs));
+ n = 1;
+ m = 3 + analysis_tool_calc_length (specs);
+ if (info->std_error_flag)
+ n++;
+ if (info->es_type == moving_average_type_des) {
+ n++;
+ m++;
+ }
+ dao_adjust (dao,
+ n * g_slist_length (info->base.input), m);
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
return analysis_tool_generic_clean (specs);
Modified: trunk/src/tools/analysis-tools.h
==============================================================================
--- trunk/src/tools/analysis-tools.h (original)
+++ trunk/src/tools/analysis-tools.h Fri Sep 26 05:55:58 2008
@@ -111,12 +111,17 @@
typedef enum {
moving_average_type_ses_h = 0,
- moving_average_type_ses_r
+ moving_average_type_ses_r,
+ moving_average_type_des,
+ moving_average_type_ates,
+ moving_average_type_mtes
} exponential_smoothing_type_t;
typedef struct {
analysis_tools_data_generic_t base;
gnm_float damp_fact;
+ gnm_float g_damp_fact;
+ gnm_float s_damp_fact;
int std_error_flag;
int df;
gboolean show_graph;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]