Commit ccb27373 authored by Jukka-Pekka Iivonen's avatar Jukka-Pekka Iivonen Committed by jpekka

*src/dialog-analysis-tools.c, src/analysis-tools.c: Added some error

1999-07-06  Jukka-Pekka Iivonen  <iivonen@iki.fi>

	*src/dialog-analysis-tools.c, src/analysis-tools.c: Added some
 	error checks, not complete yet.
parent e573a85a
1999-07-06 Jukka-Pekka Iivonen <iivonen@iki.fi>
*src/dialog-analysis-tools.c, src/analysis-tools.c: Added some
error checks, not complete yet.
1999-07-06 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/dialog-analysis-tools.c, src/analysis-tools.c: Added output
......
1999-07-06 Jukka-Pekka Iivonen <iivonen@iki.fi>
*src/dialog-analysis-tools.c, src/analysis-tools.c: Added some
error checks, not complete yet.
1999-07-06 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/dialog-analysis-tools.c, src/analysis-tools.c: Added output
......
1999-07-06 Jukka-Pekka Iivonen <iivonen@iki.fi>
*src/dialog-analysis-tools.c, src/analysis-tools.c: Added some
error checks, not complete yet.
1999-07-06 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/dialog-analysis-tools.c, src/analysis-tools.c: Added output
......
1999-07-06 Jukka-Pekka Iivonen <iivonen@iki.fi>
*src/dialog-analysis-tools.c, src/analysis-tools.c: Added some
error checks, not complete yet.
1999-07-06 Jukka-Pekka Iivonen <iivonen@iki.fi>
* src/dialog-analysis-tools.c, src/analysis-tools.c: Added output
......
......@@ -276,7 +276,7 @@ correl(data_set_t *set_one, data_set_t *set_two, int *error_flag)
/* If columns_flag is set, the data entries are groupped by columns
* otherwise by rows.
*/
void
int
correlation_tool (Workbook *wb, Sheet *current_sheet,
Range *input_range, int columns_flag,
data_analysis_output_t *dao)
......@@ -351,6 +351,8 @@ correlation_tool (Workbook *wb, Sheet *current_sheet,
for (i=0; i<vars; i++)
free_data_set(&data_sets[i]);
return 0;
}
......@@ -400,7 +402,7 @@ covar(data_set_t *set_one, data_set_t *set_two, int *error_flag)
/* If columns_flag is set, the data entries are groupped by columns
* otherwise by rows.
*/
void
int
covariance_tool (Workbook *wb, Sheet *current_sheet,
Range *input_range, int columns_flag,
data_analysis_output_t *dao)
......@@ -475,6 +477,8 @@ covariance_tool (Workbook *wb, Sheet *current_sheet,
for (i=0; i<vars; i++)
free_data_set(&data_sets[i]);
return 0;
}
......@@ -587,10 +591,12 @@ summary_statistics(Workbook *wb, data_set_t *data_set, int vars,
set_cell (dao, 0, 13, "Count");
for (col=0; col<vars; col++) {
float_t var = (data_set[col].sqrsum -
float_t var, stdev;
var = (data_set[col].sqrsum -
data_set[col].sum2/data_set[col].n) /
(data_set[col].n - 1);
float_t stdev = sqrt(var);
stdev = sqrt(var);
data_set[col].array =
g_slist_sort(data_set[col].array,
......@@ -630,13 +636,19 @@ summary_statistics(Workbook *wb, data_set_t *data_set, int vars,
set_cell (dao, col+1, 6, buf);
/* Kurtosis */
x = kurt(&data_set[col], &error);
sprintf(buf, "%f", x);
if (data_set[col].n > 3) {
x = kurt(&data_set[col], &error);
sprintf(buf, "%f", x);
} else
sprintf(buf, "#N/A");
set_cell (dao, col+1, 7, buf);
/* Skewness */
x = skew(&data_set[col], &error);
sprintf(buf, "%f", x);
if (data_set[col].n > 2) {
x = skew(&data_set[col], &error);
sprintf(buf, "%f", x);
} else
sprintf(buf, "#N/A");
set_cell (dao, col+1, 8, buf);
/* Range */
......@@ -753,7 +765,7 @@ kth_smallest(Workbook *wb, data_set_t *data_set, int vars, int k,
/* Descriptive Statistics
*/
void
int
descriptive_stat_tool (Workbook *wb, Sheet *current_sheet,
Range *input_range, int columns_flag,
descriptive_stat_tool_t *ds,
......@@ -792,6 +804,8 @@ descriptive_stat_tool (Workbook *wb, Sheet *current_sheet,
for (i=0; i<vars; i++)
free_data_set(&data_sets[i]);
return 0;
}
......
......@@ -362,7 +362,8 @@ correlation_dialog_loop:
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto correlation_dialog_loop;
correlation_tool (wb, sheet, &range, !i, &dao);
if (correlation_tool (wb, sheet, &range, !i, &dao))
goto correlation_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......@@ -447,7 +448,8 @@ covariance_dialog_loop:
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto covariance_dialog_loop;
covariance_tool (wb, sheet, &range, !i, &dao);
if (covariance_tool (wb, sheet, &range, !i, &dao))
goto covariance_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......@@ -552,7 +554,9 @@ sampling_dialog_loop:
text = gtk_entry_get_text (GTK_ENTRY (sampling_entry[i]));
size = atoi(text);
sampling_tool (wb, sheet, &range, !i, size, &dao);
if (sampling_tool (wb, sheet, &range, !i, size, &dao))
goto sampling_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......@@ -651,7 +655,8 @@ stat_dialog_loop:
text = gtk_entry_get_text (GTK_ENTRY (ds.entry[3]));
ds.k_smallest = atoi(text);
descriptive_stat_tool(wb, sheet, &range, !i, &ds, &dao);
if (descriptive_stat_tool(wb, sheet, &range, !i, &ds, &dao))
goto stat_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......@@ -761,8 +766,9 @@ ztest_dialog_loop:
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto ztest_dialog_loop;
ztest_tool (wb, sheet, &range_input1, &range_input2, mean_diff,
var1, var2, alpha, &dao);
if (ztest_tool (wb, sheet, &range_input1, &range_input2, mean_diff,
var1, var2, alpha, &dao))
goto ztest_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......@@ -859,8 +865,9 @@ ttest_dialog_loop:
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto ttest_dialog_loop;
ttest_paired_tool (wb, sheet, &range_input1, &range_input2, mean_diff,
alpha, &dao);
if (ttest_paired_tool (wb, sheet, &range_input1, &range_input2,
mean_diff, alpha, &dao))
goto ttest_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......@@ -958,8 +965,9 @@ ttest_dialog_loop:
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto ttest_dialog_loop;
ttest_eq_var_tool (wb, sheet, &range_input1, &range_input2, mean_diff,
alpha, &dao);
if (ttest_eq_var_tool (wb, sheet, &range_input1, &range_input2,
mean_diff, alpha, &dao))
goto ttest_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......@@ -1057,8 +1065,9 @@ ttest_dialog_loop:
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto ttest_dialog_loop;
ttest_neq_var_tool (wb, sheet, &range_input1, &range_input2, mean_diff,
alpha, &dao);
if (ttest_neq_var_tool (wb, sheet, &range_input1, &range_input2,
mean_diff, alpha, &dao))
goto ttest_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......@@ -1111,7 +1120,7 @@ dialog_ftest_tool(Workbook *wb, Sheet *sheet)
gtk_widget_grab_focus (range1_entry);
ttest_dialog_loop:
ftest_dialog_loop:
selection = gnome_dialog_run (GNOME_DIALOG (dialog));
if (selection == 1) {
......@@ -1129,7 +1138,7 @@ ttest_dialog_loop:
error_in_entry(wb, range1_entry,
"You should introduce a valid cell range "
"in 'Variable 1:'");
goto ttest_dialog_loop;
goto ftest_dialog_loop;
}
text = gtk_entry_get_text (GTK_ENTRY (range2_entry));
......@@ -1140,16 +1149,17 @@ ttest_dialog_loop:
error_in_entry(wb, range2_entry,
"You should introduce a valid cell range "
"in 'Variable 2:'");
goto ttest_dialog_loop;
goto ftest_dialog_loop;
}
text = gtk_entry_get_text (GTK_ENTRY (alpha_entry));
alpha = atof(text);
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto ttest_dialog_loop;
goto ftest_dialog_loop;
ftest_tool (wb, sheet, &range_input1, &range_input2, alpha, &dao);
if (ftest_tool (wb, sheet, &range_input1, &range_input2, alpha, &dao))
goto ftest_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......
......@@ -45,37 +45,31 @@ FunctionDefinition *dialog_function_select (Workbook *wb);
void dialog_data_analysis (Workbook *wb, Sheet *sheet);
void correlation_tool (Workbook *wb, Sheet *current_sheet,
Range *input_range, int columns_flag,
data_analysis_output_t *dao);
void covariance_tool (Workbook *wb, Sheet *current_sheet,
int correlation_tool (Workbook *wb, Sheet *current_sheet,
Range *input_range, int columns_flag,
data_analysis_output_t *dao);
void descriptive_stat_tool (Workbook *wb, Sheet *current_sheet,
Range *input_range, int columns_flag,
descriptive_stat_tool_t *ds,
data_analysis_output_t *dao);
int covariance_tool (Workbook *wb, Sheet *current_sheet,
Range *input_range, int columns_flag,
data_analysis_output_t *dao);
int descriptive_stat_tool (Workbook *wb, Sheet *current_sheet,
Range *input_range, int columns_flag,
descriptive_stat_tool_t *ds,
data_analysis_output_t *dao);
int sampling_tool (Workbook *wb, Sheet *sheet, Range *input_range,
gboolean periodic_flag, int size,
data_analysis_output_t *dao);
int ftest_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
Range *input_range2, float_t alpha,
data_analysis_output_t *dao);
int ttest_paired_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
Range *input_range2, float_t mean_diff, float_t alpha,
data_analysis_output_t *dao);
int ttest_eq_var_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
Range *input_range2, float_t mean_diff, float_t alpha,
data_analysis_output_t *dao);
int ttest_neq_var_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
Range *input_range2, float_t mean_diff, float_t alpha,
data_analysis_output_t *dao);
int ztest_tool (Workbook *wb, Sheet *sheet, Range *range_input1,
Range *range_input2, float_t mean_diff,
float_t var1, float_t var2, float_t alpha,
......
......@@ -362,7 +362,8 @@ correlation_dialog_loop:
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto correlation_dialog_loop;
correlation_tool (wb, sheet, &range, !i, &dao);
if (correlation_tool (wb, sheet, &range, !i, &dao))
goto correlation_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......@@ -447,7 +448,8 @@ covariance_dialog_loop:
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto covariance_dialog_loop;
covariance_tool (wb, sheet, &range, !i, &dao);
if (covariance_tool (wb, sheet, &range, !i, &dao))
goto covariance_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......@@ -552,7 +554,9 @@ sampling_dialog_loop:
text = gtk_entry_get_text (GTK_ENTRY (sampling_entry[i]));
size = atoi(text);
sampling_tool (wb, sheet, &range, !i, size, &dao);
if (sampling_tool (wb, sheet, &range, !i, size, &dao))
goto sampling_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......@@ -651,7 +655,8 @@ stat_dialog_loop:
text = gtk_entry_get_text (GTK_ENTRY (ds.entry[3]));
ds.k_smallest = atoi(text);
descriptive_stat_tool(wb, sheet, &range, !i, &ds, &dao);
if (descriptive_stat_tool(wb, sheet, &range, !i, &ds, &dao))
goto stat_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......@@ -761,8 +766,9 @@ ztest_dialog_loop:
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto ztest_dialog_loop;
ztest_tool (wb, sheet, &range_input1, &range_input2, mean_diff,
var1, var2, alpha, &dao);
if (ztest_tool (wb, sheet, &range_input1, &range_input2, mean_diff,
var1, var2, alpha, &dao))
goto ztest_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......@@ -859,8 +865,9 @@ ttest_dialog_loop:
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto ttest_dialog_loop;
ttest_paired_tool (wb, sheet, &range_input1, &range_input2, mean_diff,
alpha, &dao);
if (ttest_paired_tool (wb, sheet, &range_input1, &range_input2,
mean_diff, alpha, &dao))
goto ttest_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......@@ -958,8 +965,9 @@ ttest_dialog_loop:
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto ttest_dialog_loop;
ttest_eq_var_tool (wb, sheet, &range_input1, &range_input2, mean_diff,
alpha, &dao);
if (ttest_eq_var_tool (wb, sheet, &range_input1, &range_input2,
mean_diff, alpha, &dao))
goto ttest_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......@@ -1057,8 +1065,9 @@ ttest_dialog_loop:
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto ttest_dialog_loop;
ttest_neq_var_tool (wb, sheet, &range_input1, &range_input2, mean_diff,
alpha, &dao);
if (ttest_neq_var_tool (wb, sheet, &range_input1, &range_input2,
mean_diff, alpha, &dao))
goto ttest_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......@@ -1111,7 +1120,7 @@ dialog_ftest_tool(Workbook *wb, Sheet *sheet)
gtk_widget_grab_focus (range1_entry);
ttest_dialog_loop:
ftest_dialog_loop:
selection = gnome_dialog_run (GNOME_DIALOG (dialog));
if (selection == 1) {
......@@ -1129,7 +1138,7 @@ ttest_dialog_loop:
error_in_entry(wb, range1_entry,
"You should introduce a valid cell range "
"in 'Variable 1:'");
goto ttest_dialog_loop;
goto ftest_dialog_loop;
}
text = gtk_entry_get_text (GTK_ENTRY (range2_entry));
......@@ -1140,16 +1149,17 @@ ttest_dialog_loop:
error_in_entry(wb, range2_entry,
"You should introduce a valid cell range "
"in 'Variable 2:'");
goto ttest_dialog_loop;
goto ftest_dialog_loop;
}
text = gtk_entry_get_text (GTK_ENTRY (alpha_entry));
alpha = atof(text);
if (parse_output(output, sheet, output_range_entry, wb, &dao))
goto ttest_dialog_loop;
goto ftest_dialog_loop;
ftest_tool (wb, sheet, &range_input1, &range_input2, alpha, &dao);
if (ftest_tool (wb, sheet, &range_input1, &range_input2, alpha, &dao))
goto ftest_dialog_loop;
workbook_focus_sheet(sheet);
gnome_dialog_close (GNOME_DIALOG (dialog));
......
......@@ -45,37 +45,31 @@ FunctionDefinition *dialog_function_select (Workbook *wb);
void dialog_data_analysis (Workbook *wb, Sheet *sheet);
void correlation_tool (Workbook *wb, Sheet *current_sheet,
Range *input_range, int columns_flag,
data_analysis_output_t *dao);
void covariance_tool (Workbook *wb, Sheet *current_sheet,
int correlation_tool (Workbook *wb, Sheet *current_sheet,
Range *input_range, int columns_flag,
data_analysis_output_t *dao);
void descriptive_stat_tool (Workbook *wb, Sheet *current_sheet,
Range *input_range, int columns_flag,
descriptive_stat_tool_t *ds,
data_analysis_output_t *dao);
int covariance_tool (Workbook *wb, Sheet *current_sheet,
Range *input_range, int columns_flag,
data_analysis_output_t *dao);
int descriptive_stat_tool (Workbook *wb, Sheet *current_sheet,
Range *input_range, int columns_flag,
descriptive_stat_tool_t *ds,
data_analysis_output_t *dao);
int sampling_tool (Workbook *wb, Sheet *sheet, Range *input_range,
gboolean periodic_flag, int size,
data_analysis_output_t *dao);
int ftest_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
Range *input_range2, float_t alpha,
data_analysis_output_t *dao);
int ttest_paired_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
Range *input_range2, float_t mean_diff, float_t alpha,
data_analysis_output_t *dao);
int ttest_eq_var_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
Range *input_range2, float_t mean_diff, float_t alpha,
data_analysis_output_t *dao);
int ttest_neq_var_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
Range *input_range2, float_t mean_diff, float_t alpha,
data_analysis_output_t *dao);
int ztest_tool (Workbook *wb, Sheet *sheet, Range *range_input1,
Range *range_input2, float_t mean_diff,
float_t var1, float_t var2, float_t alpha,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment