gnumeric r16827 - in trunk/src: dialogs tools
- From: guelzow svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16827 - in trunk/src: dialogs tools
- Date: Thu, 25 Sep 2008 22:39:14 +0000 (UTC)
Author: guelzow
Date: Thu Sep 25 22:39:14 2008
New Revision: 16827
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16827&view=rev
Log:
2008-09-25 Andreas J. Guelzow <aguelzow pyrshep ca>
* analysis-tools.h (analysis_tools_data_exponential_smoothing_t):
add field
(exponential_smoothing_type_t): new
* analysis-tools.c (analysis_tool_exponential_smoothing_engine_run):
add handling of Robert's version of simple exponential smoothing
2008-09-25 Andreas J. Guelzow <aguelzow pyrshep ca>
* exp-smoothing.glade: enable "Roberts".
* dialog-analysis-tools.c (exp_smoothing_tool_ok_clicked_cb):
check for type of smoothing
(exp_smoothing_group): new
Modified:
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/src/dialogs/dialog-analysis-tools.c
==============================================================================
--- trunk/src/dialogs/dialog-analysis-tools.c (original)
+++ trunk/src/dialogs/dialog-analysis-tools.c Thu Sep 25 22:39:14 2008
@@ -131,6 +131,12 @@
NULL
};
+static char const * const exp_smoothing_group[] = {
+ "ses-h-button",
+ "ses-r-button",
+ NULL
+};
+
typedef struct {
@@ -2310,6 +2316,8 @@
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);
Modified: trunk/src/dialogs/exp-smoothing.glade
==============================================================================
--- trunk/src/dialogs/exp-smoothing.glade (original)
+++ trunk/src/dialogs/exp-smoothing.glade Thu Sep 25 22:39:14 2008
@@ -34,48 +34,6 @@
<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>
@@ -113,6 +71,48 @@
<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>
@@ -134,24 +134,18 @@
<placeholder/>
</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>
<child>
<widget class="GtkRadioButton" id="ses-r-button">
<property name="visible">True</property>
- <property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Simple exponential smoothing (Roberts, 1959)</property>
<property name="response_id">0</property>
@@ -164,14 +158,19 @@
</packing>
</child>
<child>
- <widget class="GtkRadioButton" id="ses-h-button">
+ <widget class="GtkRadioButton" id="wma-button">
<property name="visible">True</property>
+ <property name="sensitive">False</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">Simple exponential smoothing (Hunter, 1986)</property>
+ <property name="label" translatable="yes">Double 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">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
</child>
</widget>
<packing>
@@ -203,6 +202,18 @@
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<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>
+ <child>
<widget class="GtkSpinButton" id="damping-fact-spin">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -216,18 +227,6 @@
<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>
@@ -252,35 +251,28 @@
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<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>
<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>
@@ -306,12 +298,18 @@
</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>
@@ -319,19 +317,20 @@
</packing>
</child>
<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>
</widget>
Modified: trunk/src/tools/analysis-tools.c
==============================================================================
--- trunk/src/tools/analysis-tools.c (original)
+++ trunk/src/tools/analysis-tools.c Thu Sep 25 22:39:14 2008
@@ -3854,7 +3854,7 @@
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\xb1 =\" * 0.000"));
+ dao_set_format (dao, 0, 1, 0, 1, _("\"\xce\xbb =\" * 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);
dao->offset_row = 2;
@@ -3871,7 +3871,7 @@
gint *mover;
guint delta_x = 1;
guint delta_y = 1;
- gint row, base;
+ gint row, base, se_adj;
Sheet *sheet;
if (info->base.labels) {
@@ -3930,36 +3930,43 @@
NULL);
}
- { /* F(t+1) = F(t) + (1 - damp_fact) * ( A(t) - F(t) ) */
-
- dao_set_cell_expr (dao, col, 1,
- gnm_expr_new_funcall1 (fd_index,
- gnm_expr_copy (expr_input)));
+
+ 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;
- for (row = 2; row <= height; row++, (*mover)++) {
- GnmExpr const *A;
- GnmExpr const *F;
-
- 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));
- }
base = 1;
-
+ se_adj = 0;
}
-
-
+
+ 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_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));
+ }
+
if (info->std_error_flag) {
col++;
dao_set_italic (dao, col, 0, col, 0);
@@ -3986,7 +3993,7 @@
(gnm_expr_new_funcall2
(fd_sumxmy2,
expr_offset,
- make_rangeref (-1, - row + base + 1, -1, 0)),
+ make_rangeref (-1, - row + base + se_adj + 1, -1, se_adj)),
GNM_EXPR_OP_DIV,
gnm_expr_new_constant (value_new_int
(row - base - info->df)))));
Modified: trunk/src/tools/analysis-tools.h
==============================================================================
--- trunk/src/tools/analysis-tools.h (original)
+++ trunk/src/tools/analysis-tools.h Thu Sep 25 22:39:14 2008
@@ -109,12 +109,18 @@
/************** Exponential Smoothing *************/
+typedef enum {
+ moving_average_type_ses_h = 0,
+ moving_average_type_ses_r
+} exponential_smoothing_type_t;
+
typedef struct {
analysis_tools_data_generic_t base;
gnm_float damp_fact;
int std_error_flag;
int df;
gboolean show_graph;
+ exponential_smoothing_type_t es_type;
} analysis_tools_data_exponential_smoothing_t;
gboolean analysis_tool_exponential_smoothing_engine (data_analysis_output_t *dao, gpointer specs,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]