X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Fmode.h;fp=src%2Fmath%2Fmode.h;h=b2d1441ac70fbb6a9bb5baab70339761c2a1b36d;hb=101250dc9f516758bd9d13f869f1a770d6dd1ca3;hp=0000000000000000000000000000000000000000;hpb=b9f712f8911170fcc049c6d7d83b6887185de4dd;p=pspp
diff --git a/src/math/mode.h b/src/math/mode.h
new file mode 100644
index 0000000000..b2d1441ac7
--- /dev/null
+++ b/src/math/mode.h
@@ -0,0 +1,46 @@
+/* PSPP - a program for statistical analysis.
+ Copyright (C) 2004, 2008, 2009, 2022 Free Software Foundation, Inc.
+
+ 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 3 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, see . */
+
+#ifndef MATH_MODE_H
+#define MATH_MODE_H 1
+
+#include
+
+#include "order-stats.h"
+
+/* To calculate the mode:
+
+ - Create a "struct mode" with mode_create().
+ - Feed in the data with order_stats_accumulate() or
+ order_stats_accumulate_idx(). The data must be in sorted order: if
+ necessary, use one of the sorting functions from sort.h to sort them.
+ - The members of "struct mode" then designate the mode.
+ - Destroy the data structure with statistic_destroy().
+*/
+
+struct mode
+{
+ struct order_stats parent;
+
+ /* These are initialized by order_stats_accumulate{_idx}(). */
+ double mode; /* The value of the smallest mode, if 'n_modes' > 0. */
+ double mode_weight; /* The weight of each mode, if 'n_modes' > 0. */
+ size_t n_modes; /* The number of modes. */
+};
+
+struct mode *mode_create (void);
+
+#endif /* mode.h */