diff options
Diffstat (limited to 'gsl-1.9/statistics')
54 files changed, 5047 insertions, 0 deletions
diff --git a/gsl-1.9/statistics/ChangeLog b/gsl-1.9/statistics/ChangeLog new file mode 100644 index 0000000..43a04ed --- /dev/null +++ b/gsl-1.9/statistics/ChangeLog @@ -0,0 +1,118 @@ +2006-01-07 Brian Gough <bjg@network-theory.co.uk> + + * test_float_source.c: additional tests for NaNs + + * minmax_source.c: handle NaNs correctly, if any element is NaN + then the max and min are NaN + +Sat Jul 15 12:23:09 2000 Brian Gough <bjg@network-theory.co.uk> + + * test_nist.c: added url/reference to the original NIST datasets + +Thu May 4 15:11:11 2000 Brian Gough <bjg@network-theory.co.uk> + + * covariance.c: added covariance function + +Wed Mar 8 15:29:19 2000 Brian Gough <bjg@network-theory.co.uk> + + * Function Name Reorganization: The function suffix "_with_mean" + has been changed to "_m", the function suffix "_with_mean_and_sd" + has been changed to "_m_sd". The variance function est_variance + has been changed to simply _variance, (similarly for est_sd, which + is now _sd), while the function _variance is now + _variance_with_fixed_mean (and _sd is _sd_with_fixed_mean). + +Wed Mar 1 11:09:21 2000 Brian Gough <bjg@network-theory.co.uk> + + * wabsdev.c wabsdev_source.c wkurtosis.c wkurtosis_source.c + wmean.c wmean_source.c wskew.c wskew_source.c wvariance.c + wvariance_source.c: added support for weighted statistics + + * removed source.h (no longer used) + +Tue Feb 29 10:35:23 2000 Brian Gough <bjg@network-theory.co.uk> + + * changed arguments of pvariance and ttest to have consistent form + (DATA,STRIDE,SIZE) + +Mon Feb 28 20:29:08 2000 Brian Gough <bjg@network-theory.co.uk> + + * removed sort function since this is now available in the sort + directory. + + * converted all functions to take a stride argument, in + preparation for supporting statistics on vectors + +1998-11-06 <bjg@ancho.lanl.gov> + + * test.c: added prototype for memcpy using #include <string.h> + +Wed Aug 12 12:34:24 1998 Brian Gough <bjg@vvv.lanl.gov> + + * quantiles.c: Renamed percentile to quantile throughout. This is + the correct name for the quantity, mathematically speaking. + +Wed Aug 5 12:34:58 1998 Brian Gough <bjg@vvv.lanl.gov> + + * mkheaders.pl: script to generate all the headers from + gsl_statistics_int.h + + * test.h: removed test.h, not needed + + * test.c: added tests for all types + + * converted functions to use 'long double' for internal calculations, + for extra range. + + * converted all the functions to use templates_on.h and + templates_off.h + +Mon Jun 1 23:47:23 1998 Brian Gough <bjg@vvv.lanl.gov> + + * lag1_source.c: added a new function to compute the + lag1-autocorrelation + + * test_nist.c: added some numerical accuracy tests from NIST + +Fri Apr 10 15:11:51 1998 Brian Gough <bjg@vvv.lanl.gov> + + * renamed pooled_variance.c, etc to p_variance to avoid linker + complaints about long filenames on some platforms + +Wed Apr 8 18:11:48 1998 Brian Gough <bjg@vvv.lanl.gov> + + * Added a new recurrence algorithm for the mean, variance, skew + and kurtosis. It uses a running value which is less likely to + overflow than a global sum. + +Mon Mar 30 22:18:59 1998 Brian Gough <bjg@vvv.lanl.gov> + + * completely reorganised the source system to use macros as + a primitive form of templates. + +Sun Mar 29 16:25:24 1998 Brian Gough <bjg@vvv.lanl.gov> + + * make everything const where possible (to reduce the chance of errors) + +Sun Mar 22 23:34:05 1998 Brian Gough <bjg@vvv.lanl.gov> + + * skew.c: compute the skewness of a dataset + + * percentiles.c: find a given percentile from a sorted dataset + + * minmax.c: allow the user to find the indices of the max/min + data points, in addition to the max/min values + + * median.c: compute the median of a sorted dataset + + * kurtosis.c: compute the kurtosis + + * absdev.c: compute absolute deviations + + * split statistics functions into double versions (gsl_stats) and + integer versions (gsl_stats_int). There is a script + (convert_double_to_int.pl) to make the integer versions from the + double versions. + + + diff --git a/gsl-1.9/statistics/Makefile.am b/gsl-1.9/statistics/Makefile.am new file mode 100644 index 0000000..f2c3adc --- /dev/null +++ b/gsl-1.9/statistics/Makefile.am @@ -0,0 +1,19 @@ +## Process this file with automake to produce Makefile.in + +noinst_LTLIBRARIES = libgslstatistics.la + +pkginclude_HEADERS = gsl_statistics.h gsl_statistics_char.h gsl_statistics_double.h gsl_statistics_float.h gsl_statistics_int.h gsl_statistics_long.h gsl_statistics_long_double.h gsl_statistics_short.h gsl_statistics_uchar.h gsl_statistics_uint.h gsl_statistics_ulong.h gsl_statistics_ushort.h + +INCLUDES= -I$(top_builddir) -I$(top_srcdir) + +libgslstatistics_la_SOURCES = mean.c variance.c absdev.c skew.c kurtosis.c lag1.c p_variance.c minmax.c ttest.c median.c covariance.c quantiles.c wmean.c wvariance.c wabsdev.c wskew.c wkurtosis.c + +noinst_HEADERS = mean_source.c variance_source.c covariance_source.c absdev_source.c skew_source.c kurtosis_source.c lag1_source.c p_variance_source.c minmax_source.c ttest_source.c median_source.c quantiles_source.c wmean_source.c wvariance_source.c wabsdev_source.c wskew_source.c wkurtosis_source.c test_float_source.c test_int_source.c + +check_PROGRAMS = test +TESTS = $(check_PROGRAMS) + +test_SOURCES = test.c test_nist.c +test_LDADD = libgslstatistics.la ../sort/libgslsort.la ../ieee-utils/libgslieeeutils.la ../err/libgslerr.la ../test/libgsltest.la ../sys/libgslsys.la ../utils/libutils.la + + diff --git a/gsl-1.9/statistics/Makefile.in b/gsl-1.9/statistics/Makefile.in new file mode 100644 index 0000000..049dde5 --- /dev/null +++ b/gsl-1.9/statistics/Makefile.in @@ -0,0 +1,547 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +check_PROGRAMS = test$(EXEEXT) +subdir = statistics +DIST_COMMON = $(noinst_HEADERS) $(pkginclude_HEADERS) \ + $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog TODO +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libgslstatistics_la_LIBADD = +am_libgslstatistics_la_OBJECTS = mean.lo variance.lo absdev.lo skew.lo \ + kurtosis.lo lag1.lo p_variance.lo minmax.lo ttest.lo median.lo \ + covariance.lo quantiles.lo wmean.lo wvariance.lo wabsdev.lo \ + wskew.lo wkurtosis.lo +libgslstatistics_la_OBJECTS = $(am_libgslstatistics_la_OBJECTS) +am_test_OBJECTS = test.$(OBJEXT) test_nist.$(OBJEXT) +test_OBJECTS = $(am_test_OBJECTS) +test_DEPENDENCIES = libgslstatistics.la ../sort/libgslsort.la \ + ../ieee-utils/libgslieeeutils.la ../err/libgslerr.la \ + ../test/libgsltest.la ../sys/libgslsys.la ../utils/libutils.la +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = +am__depfiles_maybe = +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libgslstatistics_la_SOURCES) $(test_SOURCES) +DIST_SOURCES = $(libgslstatistics_la_SOURCES) $(test_SOURCES) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(pkgincludedir)" +pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(noinst_HEADERS) $(pkginclude_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GSL_CFLAGS = @GSL_CFLAGS@ +GSL_LIBS = @GSL_LIBS@ +GSL_LT_CBLAS_VERSION = @GSL_LT_CBLAS_VERSION@ +GSL_LT_VERSION = @GSL_LT_VERSION@ +HAVE_AIX_IEEE_INTERFACE = @HAVE_AIX_IEEE_INTERFACE@ +HAVE_DARWIN86_IEEE_INTERFACE = @HAVE_DARWIN86_IEEE_INTERFACE@ +HAVE_DARWIN_IEEE_INTERFACE = @HAVE_DARWIN_IEEE_INTERFACE@ +HAVE_EXTENDED_PRECISION_REGISTERS = @HAVE_EXTENDED_PRECISION_REGISTERS@ +HAVE_FREEBSD_IEEE_INTERFACE = @HAVE_FREEBSD_IEEE_INTERFACE@ +HAVE_GNUM68K_IEEE_INTERFACE = @HAVE_GNUM68K_IEEE_INTERFACE@ +HAVE_GNUPPC_IEEE_INTERFACE = @HAVE_GNUPPC_IEEE_INTERFACE@ +HAVE_GNUSPARC_IEEE_INTERFACE = @HAVE_GNUSPARC_IEEE_INTERFACE@ +HAVE_GNUX86_IEEE_INTERFACE = @HAVE_GNUX86_IEEE_INTERFACE@ +HAVE_HPUX11_IEEE_INTERFACE = @HAVE_HPUX11_IEEE_INTERFACE@ +HAVE_HPUX_IEEE_INTERFACE = @HAVE_HPUX_IEEE_INTERFACE@ +HAVE_IEEE_COMPARISONS = @HAVE_IEEE_COMPARISONS@ +HAVE_IEEE_DENORMALS = @HAVE_IEEE_DENORMALS@ +HAVE_INLINE = @HAVE_INLINE@ +HAVE_IRIX_IEEE_INTERFACE = @HAVE_IRIX_IEEE_INTERFACE@ +HAVE_NETBSD_IEEE_INTERFACE = @HAVE_NETBSD_IEEE_INTERFACE@ +HAVE_OPENBSD_IEEE_INTERFACE = @HAVE_OPENBSD_IEEE_INTERFACE@ +HAVE_OS2EMX_IEEE_INTERFACE = @HAVE_OS2EMX_IEEE_INTERFACE@ +HAVE_PRINTF_LONGDOUBLE = @HAVE_PRINTF_LONGDOUBLE@ +HAVE_SOLARIS_IEEE_INTERFACE = @HAVE_SOLARIS_IEEE_INTERFACE@ +HAVE_SUNOS4_IEEE_INTERFACE = @HAVE_SUNOS4_IEEE_INTERFACE@ +HAVE_TRU64_IEEE_INTERFACE = @HAVE_TRU64_IEEE_INTERFACE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ +MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ +MAKEINFO = @MAKEINFO@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +RELEASED = @RELEASED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__leading_dot = @am__leading_dot@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +noinst_LTLIBRARIES = libgslstatistics.la +pkginclude_HEADERS = gsl_statistics.h gsl_statistics_char.h gsl_statistics_double.h gsl_statistics_float.h gsl_statistics_int.h gsl_statistics_long.h gsl_statistics_long_double.h gsl_statistics_short.h gsl_statistics_uchar.h gsl_statistics_uint.h gsl_statistics_ulong.h gsl_statistics_ushort.h +INCLUDES = -I$(top_builddir) -I$(top_srcdir) +libgslstatistics_la_SOURCES = mean.c variance.c absdev.c skew.c kurtosis.c lag1.c p_variance.c minmax.c ttest.c median.c covariance.c quantiles.c wmean.c wvariance.c wabsdev.c wskew.c wkurtosis.c +noinst_HEADERS = mean_source.c variance_source.c covariance_source.c absdev_source.c skew_source.c kurtosis_source.c lag1_source.c p_variance_source.c minmax_source.c ttest_source.c median_source.c quantiles_source.c wmean_source.c wvariance_source.c wabsdev_source.c wskew_source.c wkurtosis_source.c test_float_source.c test_int_source.c +TESTS = $(check_PROGRAMS) +test_SOURCES = test.c test_nist.c +test_LDADD = libgslstatistics.la ../sort/libgslsort.la ../ieee-utils/libgslieeeutils.la ../err/libgslerr.la ../test/libgsltest.la ../sys/libgslsys.la ../utils/libutils.la +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps statistics/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu --ignore-deps statistics/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libgslstatistics.la: $(libgslstatistics_la_OBJECTS) $(libgslstatistics_la_DEPENDENCIES) + $(LINK) $(libgslstatistics_la_LDFLAGS) $(libgslstatistics_la_OBJECTS) $(libgslstatistics_la_LIBADD) $(LIBS) + +clean-checkPROGRAMS: + @list='$(check_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +test$(EXEEXT): $(test_OBJECTS) $(test_DEPENDENCIES) + @rm -f test$(EXEEXT) + $(LINK) $(test_LDFLAGS) $(test_OBJECTS) $(test_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +.c.o: + $(COMPILE) -c $< + +.c.obj: + $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: + $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: +install-pkgincludeHEADERS: $(pkginclude_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(pkgincludedir)" || $(mkdir_p) "$(DESTDIR)$(pkgincludedir)" + @list='$(pkginclude_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(pkgincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgincludedir)/$$f'"; \ + $(pkgincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgincludedir)/$$f"; \ + done + +uninstall-pkgincludeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(pkginclude_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(pkgincludedir)/$$f'"; \ + rm -f "$(DESTDIR)$(pkgincludedir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + echo "SKIP: $$tst"; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + skipped="($$skip tests were not run)"; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + test -z "$$skipped" || echo "$$skipped"; \ + test -z "$$report" || echo "$$report"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(pkgincludedir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-pkgincludeHEADERS + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am uninstall-pkgincludeHEADERS + +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool \ + clean-noinstLTLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man \ + install-pkgincludeHEADERS install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-info-am \ + uninstall-pkgincludeHEADERS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/gsl-1.9/statistics/TODO b/gsl-1.9/statistics/TODO new file mode 100644 index 0000000..ca5a984 --- /dev/null +++ b/gsl-1.9/statistics/TODO @@ -0,0 +1,102 @@ +* From: James Theiler <jt@lanl.gov> +To: John Lamb <J.D.Lamb@btinternet.com> +Cc: gsl-discuss@sources.redhat.com +Subject: Re: Collecting statistics for time dependent data? +Date: Thu, 9 Dec 2004 14:18:36 -0700 (MST) + +On Thu, 9 Dec 2004, John Lamb wrote: + +] Raimondo Giammanco wrote: +] > Hello, +] > +] > I was wondering if there is a way to compute "running" statistics with +] > gsl. +] > +] Yes you can do it, but there's nothing in GSL that does it and its eay +] enough that you don't need GSL. Something like (untested) +] +] double update_mean( double* mean, int* n, double x ){ +] if( *n == 1 ) +] *mean = x; +] else +] *mean = (1 - (double)1 / *n ) * *mean + x / n; +] } +] +] will work and you can derive a similar method for updating the variance +] using the usual textbook formula. +] +] var[x] = (1/n) sum x^2_i - mean(x)^2 +] +] I don't know if there is a method that avoids the rounding errors. I +] don't know why so many textbooks repeat this formula without the +] slightest warning that it can go so badly wrong. +] +] + +Stably updating mean and variance is remarkably nontrivial. There was +a series of papers in Comm ACM that discussed the issue; the final one +(that I know of) refers back to the earlier ones, and it can be found +in D.H.D. West, Updating mean and variance estimates: an improved +method, Comm ACM 22:9, 532 (1979) [* I see Luke Stras just sent this +reference! *]. I'll just copy out the pseudocode since the paper is +old enough that it might not be easy to find. This, by the way, is +generalized for weighted data, so it assumes that you get a weight and +a data value (W_i and X_i) that you use to update the estimates XBAR +and S2: + + SUMW = W_1 + M = X_1 + T = 0 + For i=2,3,...,n + { + Q = X_i - M + TEMP = SUM + W_i // typo: He meant SUMW + R = Q*W_i/TEMP + M = M + R + T = T + R*SUMW*Q + SUMW = TEMP + } + XBAR = M + S2 = T*n/((n-1)*SUMW) + + + +jt + +-- +James Theiler Space and Remote Sensing Sciences +MS-B244, ISR-2, LANL Los Alamos National Laboratory +Los Alamos, NM 87545 http://nis-www.lanl.gov/~jt + + +* Look at STARPAC ftp://ftp.ucar.edu/starpac/ and Statlib +http://lib.stat.cmu.edu/ for more ideas + +* Try using the Kahan summation formula to improve accuracy for the +NIST tests (see Brian for details, below is a sketch of the algorithm). + + sum = x(1) + c = 0 + + DO i = 2, 1000000, 1 + y = x(i) - c + t = sum + y + c = (t - sum) - y + sum = t + ENDDO + +* Prevent incorrect use of unsorted data for quartile calculations +using a typedef for sorted data (?) + +* Rejection of outliers + +* Time series. Auto correlation, cross-correlation, smoothing (moving +average), detrending, various econometric things. Integrated +quantities (area under the curve). Interpolation of noisy data/fitting +-- maybe add that to the existing interpolation stuff.What about +missing data and gaps? + + There is a new GNU package called gretl which does econometrics + +* Statistical tests (equal means, equal variance, etc). + diff --git a/gsl-1.9/statistics/absdev.c b/gsl-1.9/statistics/absdev.c new file mode 100644 index 0000000..eb2bde9 --- /dev/null +++ b/gsl-1.9/statistics/absdev.c @@ -0,0 +1,70 @@ +#include <config.h> +#include <math.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "absdev_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "absdev_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "absdev_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "absdev_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "absdev_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "absdev_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "absdev_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "absdev_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "absdev_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "absdev_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "absdev_source.c" +#include "templates_off.h" +#undef BASE_CHAR + diff --git a/gsl-1.9/statistics/absdev_source.c b/gsl-1.9/statistics/absdev_source.c new file mode 100644 index 0000000..b0d94b6 --- /dev/null +++ b/gsl-1.9/statistics/absdev_source.c @@ -0,0 +1,49 @@ +/* statistics/absdev_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +double +FUNCTION(gsl_stats,absdev) (const BASE data[], const size_t stride, const size_t n) +{ + const double mean = FUNCTION(gsl_stats,mean)(data, stride, n); + return FUNCTION(gsl_stats,absdev_m)(data, stride, n, mean); +} + +double +FUNCTION(gsl_stats,absdev_m) (const BASE data[], + const size_t stride, + const size_t n, + const double mean) +{ + /* takes a dataset and finds the absolute deviation */ + + double sum = 0, absdev; + size_t i; + + /* find the sum of the absolute deviations */ + for (i = 0; i < n; i++) + { + const double delta = fabs(data[i * stride] - mean); + sum += delta; + } + + absdev = sum / n; + + return absdev; +} + diff --git a/gsl-1.9/statistics/covariance.c b/gsl-1.9/statistics/covariance.c new file mode 100644 index 0000000..4538f75 --- /dev/null +++ b/gsl-1.9/statistics/covariance.c @@ -0,0 +1,72 @@ +#include <config.h> +#include <math.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "covariance_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "covariance_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "covariance_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "covariance_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "covariance_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "covariance_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "covariance_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "covariance_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "covariance_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "covariance_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "covariance_source.c" +#include "templates_off.h" +#undef BASE_CHAR + + + diff --git a/gsl-1.9/statistics/covariance_source.c b/gsl-1.9/statistics/covariance_source.c new file mode 100644 index 0000000..411e347 --- /dev/null +++ b/gsl-1.9/statistics/covariance_source.c @@ -0,0 +1,77 @@ +/* statistics/covar_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +static double +FUNCTION(compute,covariance) (const BASE data1[], const size_t stride1, + const BASE data2[], const size_t stride2, + const size_t n, + const double mean1, const double mean2); + +static double +FUNCTION(compute,covariance) (const BASE data1[], const size_t stride1, + const BASE data2[], const size_t stride2, + const size_t n, + const double mean1, const double mean2) +{ + /* takes a dataset and finds the covariance */ + + long double covariance = 0 ; + + size_t i; + + /* find the sum of the squares */ + for (i = 0; i < n; i++) + { + const long double delta1 = (data1[i * stride1] - mean1); + const long double delta2 = (data2[i * stride2] - mean2); + covariance += (delta1 * delta2 - covariance) / (i + 1); + } + + return covariance ; +} + +double +FUNCTION(gsl_stats,covariance_m) (const BASE data1[], const size_t stride1, + const BASE data2[], const size_t stride2, + const size_t n, + const double mean1, const double mean2) +{ + const double covariance = FUNCTION(compute,covariance) (data1, stride1, + data2, stride2, + n, + mean1, mean2); + + return covariance * ((double)n / (double)(n - 1)); +} + +double +FUNCTION(gsl_stats,covariance) (const BASE data1[], const size_t stride1, + const BASE data2[], const size_t stride2, + const size_t n) +{ + const double mean1 = FUNCTION(gsl_stats,mean) (data1, stride1, n); + const double mean2 = FUNCTION(gsl_stats,mean) (data2, stride2, n); + + return FUNCTION(gsl_stats,covariance_m)(data1, stride1, + data2, stride2, + n, + mean1, mean2); +} + + diff --git a/gsl-1.9/statistics/gsl_statistics.h b/gsl-1.9/statistics/gsl_statistics.h new file mode 100644 index 0000000..9fb414f --- /dev/null +++ b/gsl-1.9/statistics/gsl_statistics.h @@ -0,0 +1,20 @@ +#ifndef __GSL_STATISTICS_H__ +#define __GSL_STATISTICS_H__ + +#include <gsl/gsl_statistics_long_double.h> +#include <gsl/gsl_statistics_double.h> +#include <gsl/gsl_statistics_float.h> + +#include <gsl/gsl_statistics_ulong.h> +#include <gsl/gsl_statistics_long.h> + +#include <gsl/gsl_statistics_uint.h> +#include <gsl/gsl_statistics_int.h> + +#include <gsl/gsl_statistics_ushort.h> +#include <gsl/gsl_statistics_short.h> + +#include <gsl/gsl_statistics_uchar.h> +#include <gsl/gsl_statistics_char.h> + +#endif /* __GSL_STATISTICS_H__ */ diff --git a/gsl-1.9/statistics/gsl_statistics_char.h b/gsl-1.9/statistics/gsl_statistics_char.h new file mode 100644 index 0000000..92f7e1b --- /dev/null +++ b/gsl-1.9/statistics/gsl_statistics_char.h @@ -0,0 +1,75 @@ +/* statistics/gsl_statistics_char.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __GSL_STATISTICS_CHAR_H__ +#define __GSL_STATISTICS_CHAR_H__ + +#include <stddef.h> + +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +__BEGIN_DECLS + +double gsl_stats_char_mean (const char data[], const size_t stride, const size_t n); +double gsl_stats_char_variance (const char data[], const size_t stride, const size_t n); +double gsl_stats_char_sd (const char data[], const size_t stride, const size_t n); +double gsl_stats_char_variance_with_fixed_mean (const char data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_char_sd_with_fixed_mean (const char data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_char_absdev (const char data[], const size_t stride, const size_t n); +double gsl_stats_char_skew (const char data[], const size_t stride, const size_t n); +double gsl_stats_char_kurtosis (const char data[], const size_t stride, const size_t n); +double gsl_stats_char_lag1_autocorrelation (const char data[], const size_t stride, const size_t n); + +double gsl_stats_char_covariance (const char data1[], const size_t stride1,const char data2[], const size_t stride2, const size_t n); + +double gsl_stats_char_variance_m (const char data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_char_sd_m (const char data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_char_absdev_m (const char data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_char_skew_m_sd (const char data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_char_kurtosis_m_sd (const char data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_char_lag1_autocorrelation_m (const char data[], const size_t stride, const size_t n, const double mean); + +double gsl_stats_char_covariance_m (const char data1[], const size_t stride1,const char data2[], const size_t stride2, const size_t n, const double mean1, const double mean2); + + +double gsl_stats_char_pvariance (const char data1[], const size_t stride1, const size_t n1, const char data2[], const size_t stride2, const size_t n2); +double gsl_stats_char_ttest (const char data1[], const size_t stride1, const size_t n1, const char data2[], const size_t stride2, const size_t n2); + +char gsl_stats_char_max (const char data[], const size_t stride, const size_t n); +char gsl_stats_char_min (const char data[], const size_t stride, const size_t n); +void gsl_stats_char_minmax (char * min, char * max, const char data[], const size_t stride, const size_t n); + +size_t gsl_stats_char_max_index (const char data[], const size_t stride, const size_t n); +size_t gsl_stats_char_min_index (const char data[], const size_t stride, const size_t n); +void gsl_stats_char_minmax_index (size_t * min_index, size_t * max_index, const char data[], const size_t stride, const size_t n); + +double gsl_stats_char_median_from_sorted_data (const char sorted_data[], const size_t stride, const size_t n) ; +double gsl_stats_char_quantile_from_sorted_data (const char sorted_data[], const size_t stride, const size_t n, const double f) ; + +__END_DECLS + +#endif /* __GSL_STATISTICS_CHAR_H__ */ diff --git a/gsl-1.9/statistics/gsl_statistics_double.h b/gsl-1.9/statistics/gsl_statistics_double.h new file mode 100644 index 0000000..f0005c5 --- /dev/null +++ b/gsl-1.9/statistics/gsl_statistics_double.h @@ -0,0 +1,93 @@ +/* statistics/gsl_statistics_double.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __GSL_STATISTICS_DOUBLE_H__ +#define __GSL_STATISTICS_DOUBLE_H__ + +#include <stddef.h> + +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +__BEGIN_DECLS + +double gsl_stats_mean (const double data[], const size_t stride, const size_t n); +double gsl_stats_variance (const double data[], const size_t stride, const size_t n); +double gsl_stats_sd (const double data[], const size_t stride, const size_t n); +double gsl_stats_variance_with_fixed_mean (const double data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_sd_with_fixed_mean (const double data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_absdev (const double data[], const size_t stride, const size_t n); +double gsl_stats_skew (const double data[], const size_t stride, const size_t n); +double gsl_stats_kurtosis (const double data[], const size_t stride, const size_t n); +double gsl_stats_lag1_autocorrelation (const double data[], const size_t stride, const size_t n); + +double gsl_stats_covariance (const double data1[], const size_t stride1,const double data2[], const size_t stride2, const size_t n); + +double gsl_stats_variance_m (const double data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_sd_m (const double data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_absdev_m (const double data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_skew_m_sd (const double data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_kurtosis_m_sd (const double data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_lag1_autocorrelation_m (const double data[], const size_t stride, const size_t n, const double mean); + +double gsl_stats_covariance_m (const double data1[], const size_t stride1,const double data2[], const size_t stride2, const size_t n, const double mean1, const double mean2); + +/* DEFINED FOR FLOATING POINT TYPES ONLY */ + +double gsl_stats_wmean (const double w[], const size_t wstride, const double data[], const size_t stride, const size_t n); +double gsl_stats_wvariance (const double w[], const size_t wstride, const double data[], const size_t stride, const size_t n); +double gsl_stats_wsd (const double w[], const size_t wstride, const double data[], const size_t stride, const size_t n); +double gsl_stats_wvariance_with_fixed_mean (const double w[], const size_t wstride, const double data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_wsd_with_fixed_mean (const double w[], const size_t wstride, const double data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_wabsdev (const double w[], const size_t wstride, const double data[], const size_t stride, const size_t n); +double gsl_stats_wskew (const double w[], const size_t wstride, const double data[], const size_t stride, const size_t n); +double gsl_stats_wkurtosis (const double w[], const size_t wstride, const double data[], const size_t stride, const size_t n); + +double gsl_stats_wvariance_m (const double w[], const size_t wstride, const double data[], const size_t stride, const size_t n, const double wmean); +double gsl_stats_wsd_m (const double w[], const size_t wstride, const double data[], const size_t stride, const size_t n, const double wmean); +double gsl_stats_wabsdev_m (const double w[], const size_t wstride, const double data[], const size_t stride, const size_t n, const double wmean); +double gsl_stats_wskew_m_sd (const double w[], const size_t wstride, const double data[], const size_t stride, const size_t n, const double wmean, const double wsd); +double gsl_stats_wkurtosis_m_sd (const double w[], const size_t wstride, const double data[], const size_t stride, const size_t n, const double wmean, const double wsd); + +/* END OF FLOATING POINT TYPES */ + +double gsl_stats_pvariance (const double data1[], const size_t stride1, const size_t n1, const double data2[], const size_t stride2, const size_t n2); +double gsl_stats_ttest (const double data1[], const size_t stride1, const size_t n1, const double data2[], const size_t stride2, const size_t n2); + +double gsl_stats_max (const double data[], const size_t stride, const size_t n); +double gsl_stats_min (const double data[], const size_t stride, const size_t n); +void gsl_stats_minmax (double * min, double * max, const double data[], const size_t stride, const size_t n); + +size_t gsl_stats_max_index (const double data[], const size_t stride, const size_t n); +size_t gsl_stats_min_index (const double data[], const size_t stride, const size_t n); +void gsl_stats_minmax_index (size_t * min_index, size_t * max_index, const double data[], const size_t stride, const size_t n); + +double gsl_stats_median_from_sorted_data (const double sorted_data[], const size_t stride, const size_t n) ; +double gsl_stats_quantile_from_sorted_data (const double sorted_data[], const size_t stride, const size_t n, const double f) ; + +__END_DECLS + +#endif /* __GSL_STATISTICS_DOUBLE_H__ */ diff --git a/gsl-1.9/statistics/gsl_statistics_float.h b/gsl-1.9/statistics/gsl_statistics_float.h new file mode 100644 index 0000000..657af7e --- /dev/null +++ b/gsl-1.9/statistics/gsl_statistics_float.h @@ -0,0 +1,93 @@ +/* statistics/gsl_statistics_float.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __GSL_STATISTICS_FLOAT_H__ +#define __GSL_STATISTICS_FLOAT_H__ + +#include <stddef.h> + +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +__BEGIN_DECLS + +double gsl_stats_float_mean (const float data[], const size_t stride, const size_t n); +double gsl_stats_float_variance (const float data[], const size_t stride, const size_t n); +double gsl_stats_float_sd (const float data[], const size_t stride, const size_t n); +double gsl_stats_float_variance_with_fixed_mean (const float data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_float_sd_with_fixed_mean (const float data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_float_absdev (const float data[], const size_t stride, const size_t n); +double gsl_stats_float_skew (const float data[], const size_t stride, const size_t n); +double gsl_stats_float_kurtosis (const float data[], const size_t stride, const size_t n); +double gsl_stats_float_lag1_autocorrelation (const float data[], const size_t stride, const size_t n); + +double gsl_stats_float_covariance (const float data1[], const size_t stride1,const float data2[], const size_t stride2, const size_t n); + +double gsl_stats_float_variance_m (const float data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_float_sd_m (const float data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_float_absdev_m (const float data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_float_skew_m_sd (const float data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_float_kurtosis_m_sd (const float data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_float_lag1_autocorrelation_m (const float data[], const size_t stride, const size_t n, const double mean); + +double gsl_stats_float_covariance_m (const float data1[], const size_t stride1,const float data2[], const size_t stride2, const size_t n, const double mean1, const double mean2); + +/* DEFINED FOR FLOATING POINT TYPES ONLY */ + +double gsl_stats_float_wmean (const float w[], const size_t wstride, const float data[], const size_t stride, const size_t n); +double gsl_stats_float_wvariance (const float w[], const size_t wstride, const float data[], const size_t stride, const size_t n); +double gsl_stats_float_wsd (const float w[], const size_t wstride, const float data[], const size_t stride, const size_t n); +double gsl_stats_float_wvariance_with_fixed_mean (const float w[], const size_t wstride, const float data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_float_wsd_with_fixed_mean (const float w[], const size_t wstride, const float data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_float_wabsdev (const float w[], const size_t wstride, const float data[], const size_t stride, const size_t n); +double gsl_stats_float_wskew (const float w[], const size_t wstride, const float data[], const size_t stride, const size_t n); +double gsl_stats_float_wkurtosis (const float w[], const size_t wstride, const float data[], const size_t stride, const size_t n); + +double gsl_stats_float_wvariance_m (const float w[], const size_t wstride, const float data[], const size_t stride, const size_t n, const double wmean); +double gsl_stats_float_wsd_m (const float w[], const size_t wstride, const float data[], const size_t stride, const size_t n, const double wmean); +double gsl_stats_float_wabsdev_m (const float w[], const size_t wstride, const float data[], const size_t stride, const size_t n, const double wmean); +double gsl_stats_float_wskew_m_sd (const float w[], const size_t wstride, const float data[], const size_t stride, const size_t n, const double wmean, const double wsd); +double gsl_stats_float_wkurtosis_m_sd (const float w[], const size_t wstride, const float data[], const size_t stride, const size_t n, const double wmean, const double wsd); + +/* END OF FLOATING POINT TYPES */ + +double gsl_stats_float_pvariance (const float data1[], const size_t stride1, const size_t n1, const float data2[], const size_t stride2, const size_t n2); +double gsl_stats_float_ttest (const float data1[], const size_t stride1, const size_t n1, const float data2[], const size_t stride2, const size_t n2); + +float gsl_stats_float_max (const float data[], const size_t stride, const size_t n); +float gsl_stats_float_min (const float data[], const size_t stride, const size_t n); +void gsl_stats_float_minmax (float * min, float * max, const float data[], const size_t stride, const size_t n); + +size_t gsl_stats_float_max_index (const float data[], const size_t stride, const size_t n); +size_t gsl_stats_float_min_index (const float data[], const size_t stride, const size_t n); +void gsl_stats_float_minmax_index (size_t * min_index, size_t * max_index, const float data[], const size_t stride, const size_t n); + +double gsl_stats_float_median_from_sorted_data (const float sorted_data[], const size_t stride, const size_t n) ; +double gsl_stats_float_quantile_from_sorted_data (const float sorted_data[], const size_t stride, const size_t n, const double f) ; + +__END_DECLS + +#endif /* __GSL_STATISTICS_FLOAT_H__ */ diff --git a/gsl-1.9/statistics/gsl_statistics_int.h b/gsl-1.9/statistics/gsl_statistics_int.h new file mode 100644 index 0000000..62ff3d1 --- /dev/null +++ b/gsl-1.9/statistics/gsl_statistics_int.h @@ -0,0 +1,75 @@ +/* statistics/gsl_statistics_int.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __GSL_STATISTICS_INT_H__ +#define __GSL_STATISTICS_INT_H__ + +#include <stddef.h> + +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +__BEGIN_DECLS + +double gsl_stats_int_mean (const int data[], const size_t stride, const size_t n); +double gsl_stats_int_variance (const int data[], const size_t stride, const size_t n); +double gsl_stats_int_sd (const int data[], const size_t stride, const size_t n); +double gsl_stats_int_variance_with_fixed_mean (const int data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_int_sd_with_fixed_mean (const int data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_int_absdev (const int data[], const size_t stride, const size_t n); +double gsl_stats_int_skew (const int data[], const size_t stride, const size_t n); +double gsl_stats_int_kurtosis (const int data[], const size_t stride, const size_t n); +double gsl_stats_int_lag1_autocorrelation (const int data[], const size_t stride, const size_t n); + +double gsl_stats_int_covariance (const int data1[], const size_t stride1,const int data2[], const size_t stride2, const size_t n); + +double gsl_stats_int_variance_m (const int data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_int_sd_m (const int data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_int_absdev_m (const int data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_int_skew_m_sd (const int data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_int_kurtosis_m_sd (const int data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_int_lag1_autocorrelation_m (const int data[], const size_t stride, const size_t n, const double mean); + +double gsl_stats_int_covariance_m (const int data1[], const size_t stride1,const int data2[], const size_t stride2, const size_t n, const double mean1, const double mean2); + + +double gsl_stats_int_pvariance (const int data1[], const size_t stride1, const size_t n1, const int data2[], const size_t stride2, const size_t n2); +double gsl_stats_int_ttest (const int data1[], const size_t stride1, const size_t n1, const int data2[], const size_t stride2, const size_t n2); + +int gsl_stats_int_max (const int data[], const size_t stride, const size_t n); +int gsl_stats_int_min (const int data[], const size_t stride, const size_t n); +void gsl_stats_int_minmax (int * min, int * max, const int data[], const size_t stride, const size_t n); + +size_t gsl_stats_int_max_index (const int data[], const size_t stride, const size_t n); +size_t gsl_stats_int_min_index (const int data[], const size_t stride, const size_t n); +void gsl_stats_int_minmax_index (size_t * min_index, size_t * max_index, const int data[], const size_t stride, const size_t n); + +double gsl_stats_int_median_from_sorted_data (const int sorted_data[], const size_t stride, const size_t n) ; +double gsl_stats_int_quantile_from_sorted_data (const int sorted_data[], const size_t stride, const size_t n, const double f) ; + +__END_DECLS + +#endif /* __GSL_STATISTICS_INT_H__ */ diff --git a/gsl-1.9/statistics/gsl_statistics_long.h b/gsl-1.9/statistics/gsl_statistics_long.h new file mode 100644 index 0000000..870922f --- /dev/null +++ b/gsl-1.9/statistics/gsl_statistics_long.h @@ -0,0 +1,75 @@ +/* statistics/gsl_statistics_long.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __GSL_STATISTICS_LONG_H__ +#define __GSL_STATISTICS_LONG_H__ + +#include <stddef.h> + +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +__BEGIN_DECLS + +double gsl_stats_long_mean (const long data[], const size_t stride, const size_t n); +double gsl_stats_long_variance (const long data[], const size_t stride, const size_t n); +double gsl_stats_long_sd (const long data[], const size_t stride, const size_t n); +double gsl_stats_long_variance_with_fixed_mean (const long data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_long_sd_with_fixed_mean (const long data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_long_absdev (const long data[], const size_t stride, const size_t n); +double gsl_stats_long_skew (const long data[], const size_t stride, const size_t n); +double gsl_stats_long_kurtosis (const long data[], const size_t stride, const size_t n); +double gsl_stats_long_lag1_autocorrelation (const long data[], const size_t stride, const size_t n); + +double gsl_stats_long_covariance (const long data1[], const size_t stride1,const long data2[], const size_t stride2, const size_t n); + +double gsl_stats_long_variance_m (const long data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_long_sd_m (const long data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_long_absdev_m (const long data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_long_skew_m_sd (const long data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_long_kurtosis_m_sd (const long data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_long_lag1_autocorrelation_m (const long data[], const size_t stride, const size_t n, const double mean); + +double gsl_stats_long_covariance_m (const long data1[], const size_t stride1,const long data2[], const size_t stride2, const size_t n, const double mean1, const double mean2); + + +double gsl_stats_long_pvariance (const long data1[], const size_t stride1, const size_t n1, const long data2[], const size_t stride2, const size_t n2); +double gsl_stats_long_ttest (const long data1[], const size_t stride1, const size_t n1, const long data2[], const size_t stride2, const size_t n2); + +long gsl_stats_long_max (const long data[], const size_t stride, const size_t n); +long gsl_stats_long_min (const long data[], const size_t stride, const size_t n); +void gsl_stats_long_minmax (long * min, long * max, const long data[], const size_t stride, const size_t n); + +size_t gsl_stats_long_max_index (const long data[], const size_t stride, const size_t n); +size_t gsl_stats_long_min_index (const long data[], const size_t stride, const size_t n); +void gsl_stats_long_minmax_index (size_t * min_index, size_t * max_index, const long data[], const size_t stride, const size_t n); + +double gsl_stats_long_median_from_sorted_data (const long sorted_data[], const size_t stride, const size_t n) ; +double gsl_stats_long_quantile_from_sorted_data (const long sorted_data[], const size_t stride, const size_t n, const double f) ; + +__END_DECLS + +#endif /* __GSL_STATISTICS_LONG_H__ */ diff --git a/gsl-1.9/statistics/gsl_statistics_long_double.h b/gsl-1.9/statistics/gsl_statistics_long_double.h new file mode 100644 index 0000000..5cc3255 --- /dev/null +++ b/gsl-1.9/statistics/gsl_statistics_long_double.h @@ -0,0 +1,93 @@ +/* statistics/gsl_statistics_long_double.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __GSL_STATISTICS_LONG_DOUBLE_H__ +#define __GSL_STATISTICS_LONG_DOUBLE_H__ + +#include <stddef.h> + +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +__BEGIN_DECLS + +double gsl_stats_long_double_mean (const long double data[], const size_t stride, const size_t n); +double gsl_stats_long_double_variance (const long double data[], const size_t stride, const size_t n); +double gsl_stats_long_double_sd (const long double data[], const size_t stride, const size_t n); +double gsl_stats_long_double_variance_with_fixed_mean (const long double data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_long_double_sd_with_fixed_mean (const long double data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_long_double_absdev (const long double data[], const size_t stride, const size_t n); +double gsl_stats_long_double_skew (const long double data[], const size_t stride, const size_t n); +double gsl_stats_long_double_kurtosis (const long double data[], const size_t stride, const size_t n); +double gsl_stats_long_double_lag1_autocorrelation (const long double data[], const size_t stride, const size_t n); + +double gsl_stats_long_double_covariance (const long double data1[], const size_t stride1,const long double data2[], const size_t stride2, const size_t n); + +double gsl_stats_long_double_variance_m (const long double data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_long_double_sd_m (const long double data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_long_double_absdev_m (const long double data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_long_double_skew_m_sd (const long double data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_long_double_kurtosis_m_sd (const long double data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_long_double_lag1_autocorrelation_m (const long double data[], const size_t stride, const size_t n, const double mean); + +double gsl_stats_long_double_covariance_m (const long double data1[], const size_t stride1,const long double data2[], const size_t stride2, const size_t n, const double mean1, const double mean2); + +/* DEFINED FOR FLOATING POINT TYPES ONLY */ + +double gsl_stats_long_double_wmean (const long double w[], const size_t wstride, const long double data[], const size_t stride, const size_t n); +double gsl_stats_long_double_wvariance (const long double w[], const size_t wstride, const long double data[], const size_t stride, const size_t n); +double gsl_stats_long_double_wsd (const long double w[], const size_t wstride, const long double data[], const size_t stride, const size_t n); +double gsl_stats_long_double_wvariance_with_fixed_mean (const long double w[], const size_t wstride, const long double data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_long_double_wsd_with_fixed_mean (const long double w[], const size_t wstride, const long double data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_long_double_wabsdev (const long double w[], const size_t wstride, const long double data[], const size_t stride, const size_t n); +double gsl_stats_long_double_wskew (const long double w[], const size_t wstride, const long double data[], const size_t stride, const size_t n); +double gsl_stats_long_double_wkurtosis (const long double w[], const size_t wstride, const long double data[], const size_t stride, const size_t n); + +double gsl_stats_long_double_wvariance_m (const long double w[], const size_t wstride, const long double data[], const size_t stride, const size_t n, const double wmean); +double gsl_stats_long_double_wsd_m (const long double w[], const size_t wstride, const long double data[], const size_t stride, const size_t n, const double wmean); +double gsl_stats_long_double_wabsdev_m (const long double w[], const size_t wstride, const long double data[], const size_t stride, const size_t n, const double wmean); +double gsl_stats_long_double_wskew_m_sd (const long double w[], const size_t wstride, const long double data[], const size_t stride, const size_t n, const double wmean, const double wsd); +double gsl_stats_long_double_wkurtosis_m_sd (const long double w[], const size_t wstride, const long double data[], const size_t stride, const size_t n, const double wmean, const double wsd); + +/* END OF FLOATING POINT TYPES */ + +double gsl_stats_long_double_pvariance (const long double data1[], const size_t stride1, const size_t n1, const long double data2[], const size_t stride2, const size_t n2); +double gsl_stats_long_double_ttest (const long double data1[], const size_t stride1, const size_t n1, const long double data2[], const size_t stride2, const size_t n2); + +long double gsl_stats_long_double_max (const long double data[], const size_t stride, const size_t n); +long double gsl_stats_long_double_min (const long double data[], const size_t stride, const size_t n); +void gsl_stats_long_double_minmax (long double * min, long double * max, const long double data[], const size_t stride, const size_t n); + +size_t gsl_stats_long_double_max_index (const long double data[], const size_t stride, const size_t n); +size_t gsl_stats_long_double_min_index (const long double data[], const size_t stride, const size_t n); +void gsl_stats_long_double_minmax_index (size_t * min_index, size_t * max_index, const long double data[], const size_t stride, const size_t n); + +double gsl_stats_long_double_median_from_sorted_data (const long double sorted_data[], const size_t stride, const size_t n) ; +double gsl_stats_long_double_quantile_from_sorted_data (const long double sorted_data[], const size_t stride, const size_t n, const double f) ; + +__END_DECLS + +#endif /* __GSL_STATISTICS_LONG_DOUBLE_H__ */ diff --git a/gsl-1.9/statistics/gsl_statistics_short.h b/gsl-1.9/statistics/gsl_statistics_short.h new file mode 100644 index 0000000..b4aebe1 --- /dev/null +++ b/gsl-1.9/statistics/gsl_statistics_short.h @@ -0,0 +1,75 @@ +/* statistics/gsl_statistics_short.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __GSL_STATISTICS_SHORT_H__ +#define __GSL_STATISTICS_SHORT_H__ + +#include <stddef.h> + +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +__BEGIN_DECLS + +double gsl_stats_short_mean (const short data[], const size_t stride, const size_t n); +double gsl_stats_short_variance (const short data[], const size_t stride, const size_t n); +double gsl_stats_short_sd (const short data[], const size_t stride, const size_t n); +double gsl_stats_short_variance_with_fixed_mean (const short data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_short_sd_with_fixed_mean (const short data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_short_absdev (const short data[], const size_t stride, const size_t n); +double gsl_stats_short_skew (const short data[], const size_t stride, const size_t n); +double gsl_stats_short_kurtosis (const short data[], const size_t stride, const size_t n); +double gsl_stats_short_lag1_autocorrelation (const short data[], const size_t stride, const size_t n); + +double gsl_stats_short_covariance (const short data1[], const size_t stride1,const short data2[], const size_t stride2, const size_t n); + +double gsl_stats_short_variance_m (const short data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_short_sd_m (const short data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_short_absdev_m (const short data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_short_skew_m_sd (const short data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_short_kurtosis_m_sd (const short data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_short_lag1_autocorrelation_m (const short data[], const size_t stride, const size_t n, const double mean); + +double gsl_stats_short_covariance_m (const short data1[], const size_t stride1,const short data2[], const size_t stride2, const size_t n, const double mean1, const double mean2); + + +double gsl_stats_short_pvariance (const short data1[], const size_t stride1, const size_t n1, const short data2[], const size_t stride2, const size_t n2); +double gsl_stats_short_ttest (const short data1[], const size_t stride1, const size_t n1, const short data2[], const size_t stride2, const size_t n2); + +short gsl_stats_short_max (const short data[], const size_t stride, const size_t n); +short gsl_stats_short_min (const short data[], const size_t stride, const size_t n); +void gsl_stats_short_minmax (short * min, short * max, const short data[], const size_t stride, const size_t n); + +size_t gsl_stats_short_max_index (const short data[], const size_t stride, const size_t n); +size_t gsl_stats_short_min_index (const short data[], const size_t stride, const size_t n); +void gsl_stats_short_minmax_index (size_t * min_index, size_t * max_index, const short data[], const size_t stride, const size_t n); + +double gsl_stats_short_median_from_sorted_data (const short sorted_data[], const size_t stride, const size_t n) ; +double gsl_stats_short_quantile_from_sorted_data (const short sorted_data[], const size_t stride, const size_t n, const double f) ; + +__END_DECLS + +#endif /* __GSL_STATISTICS_SHORT_H__ */ diff --git a/gsl-1.9/statistics/gsl_statistics_uchar.h b/gsl-1.9/statistics/gsl_statistics_uchar.h new file mode 100644 index 0000000..f51f745 --- /dev/null +++ b/gsl-1.9/statistics/gsl_statistics_uchar.h @@ -0,0 +1,75 @@ +/* statistics/gsl_statistics_uchar.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __GSL_STATISTICS_UCHAR_H__ +#define __GSL_STATISTICS_UCHAR_H__ + +#include <stddef.h> + +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +__BEGIN_DECLS + +double gsl_stats_uchar_mean (const unsigned char data[], const size_t stride, const size_t n); +double gsl_stats_uchar_variance (const unsigned char data[], const size_t stride, const size_t n); +double gsl_stats_uchar_sd (const unsigned char data[], const size_t stride, const size_t n); +double gsl_stats_uchar_variance_with_fixed_mean (const unsigned char data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_uchar_sd_with_fixed_mean (const unsigned char data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_uchar_absdev (const unsigned char data[], const size_t stride, const size_t n); +double gsl_stats_uchar_skew (const unsigned char data[], const size_t stride, const size_t n); +double gsl_stats_uchar_kurtosis (const unsigned char data[], const size_t stride, const size_t n); +double gsl_stats_uchar_lag1_autocorrelation (const unsigned char data[], const size_t stride, const size_t n); + +double gsl_stats_uchar_covariance (const unsigned char data1[], const size_t stride1,const unsigned char data2[], const size_t stride2, const size_t n); + +double gsl_stats_uchar_variance_m (const unsigned char data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_uchar_sd_m (const unsigned char data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_uchar_absdev_m (const unsigned char data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_uchar_skew_m_sd (const unsigned char data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_uchar_kurtosis_m_sd (const unsigned char data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_uchar_lag1_autocorrelation_m (const unsigned char data[], const size_t stride, const size_t n, const double mean); + +double gsl_stats_uchar_covariance_m (const unsigned char data1[], const size_t stride1,const unsigned char data2[], const size_t stride2, const size_t n, const double mean1, const double mean2); + + +double gsl_stats_uchar_pvariance (const unsigned char data1[], const size_t stride1, const size_t n1, const unsigned char data2[], const size_t stride2, const size_t n2); +double gsl_stats_uchar_ttest (const unsigned char data1[], const size_t stride1, const size_t n1, const unsigned char data2[], const size_t stride2, const size_t n2); + +unsigned char gsl_stats_uchar_max (const unsigned char data[], const size_t stride, const size_t n); +unsigned char gsl_stats_uchar_min (const unsigned char data[], const size_t stride, const size_t n); +void gsl_stats_uchar_minmax (unsigned char * min, unsigned char * max, const unsigned char data[], const size_t stride, const size_t n); + +size_t gsl_stats_uchar_max_index (const unsigned char data[], const size_t stride, const size_t n); +size_t gsl_stats_uchar_min_index (const unsigned char data[], const size_t stride, const size_t n); +void gsl_stats_uchar_minmax_index (size_t * min_index, size_t * max_index, const unsigned char data[], const size_t stride, const size_t n); + +double gsl_stats_uchar_median_from_sorted_data (const unsigned char sorted_data[], const size_t stride, const size_t n) ; +double gsl_stats_uchar_quantile_from_sorted_data (const unsigned char sorted_data[], const size_t stride, const size_t n, const double f) ; + +__END_DECLS + +#endif /* __GSL_STATISTICS_UCHAR_H__ */ diff --git a/gsl-1.9/statistics/gsl_statistics_uint.h b/gsl-1.9/statistics/gsl_statistics_uint.h new file mode 100644 index 0000000..0dba69f --- /dev/null +++ b/gsl-1.9/statistics/gsl_statistics_uint.h @@ -0,0 +1,75 @@ +/* statistics/gsl_statistics_uint.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __GSL_STATISTICS_UINT_H__ +#define __GSL_STATISTICS_UINT_H__ + +#include <stddef.h> + +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +__BEGIN_DECLS + +double gsl_stats_uint_mean (const unsigned int data[], const size_t stride, const size_t n); +double gsl_stats_uint_variance (const unsigned int data[], const size_t stride, const size_t n); +double gsl_stats_uint_sd (const unsigned int data[], const size_t stride, const size_t n); +double gsl_stats_uint_variance_with_fixed_mean (const unsigned int data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_uint_sd_with_fixed_mean (const unsigned int data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_uint_absdev (const unsigned int data[], const size_t stride, const size_t n); +double gsl_stats_uint_skew (const unsigned int data[], const size_t stride, const size_t n); +double gsl_stats_uint_kurtosis (const unsigned int data[], const size_t stride, const size_t n); +double gsl_stats_uint_lag1_autocorrelation (const unsigned int data[], const size_t stride, const size_t n); + +double gsl_stats_uint_covariance (const unsigned int data1[], const size_t stride1,const unsigned int data2[], const size_t stride2, const size_t n); + +double gsl_stats_uint_variance_m (const unsigned int data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_uint_sd_m (const unsigned int data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_uint_absdev_m (const unsigned int data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_uint_skew_m_sd (const unsigned int data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_uint_kurtosis_m_sd (const unsigned int data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_uint_lag1_autocorrelation_m (const unsigned int data[], const size_t stride, const size_t n, const double mean); + +double gsl_stats_uint_covariance_m (const unsigned int data1[], const size_t stride1,const unsigned int data2[], const size_t stride2, const size_t n, const double mean1, const double mean2); + + +double gsl_stats_uint_pvariance (const unsigned int data1[], const size_t stride1, const size_t n1, const unsigned int data2[], const size_t stride2, const size_t n2); +double gsl_stats_uint_ttest (const unsigned int data1[], const size_t stride1, const size_t n1, const unsigned int data2[], const size_t stride2, const size_t n2); + +unsigned int gsl_stats_uint_max (const unsigned int data[], const size_t stride, const size_t n); +unsigned int gsl_stats_uint_min (const unsigned int data[], const size_t stride, const size_t n); +void gsl_stats_uint_minmax (unsigned int * min, unsigned int * max, const unsigned int data[], const size_t stride, const size_t n); + +size_t gsl_stats_uint_max_index (const unsigned int data[], const size_t stride, const size_t n); +size_t gsl_stats_uint_min_index (const unsigned int data[], const size_t stride, const size_t n); +void gsl_stats_uint_minmax_index (size_t * min_index, size_t * max_index, const unsigned int data[], const size_t stride, const size_t n); + +double gsl_stats_uint_median_from_sorted_data (const unsigned int sorted_data[], const size_t stride, const size_t n) ; +double gsl_stats_uint_quantile_from_sorted_data (const unsigned int sorted_data[], const size_t stride, const size_t n, const double f) ; + +__END_DECLS + +#endif /* __GSL_STATISTICS_UINT_H__ */ diff --git a/gsl-1.9/statistics/gsl_statistics_ulong.h b/gsl-1.9/statistics/gsl_statistics_ulong.h new file mode 100644 index 0000000..761101e --- /dev/null +++ b/gsl-1.9/statistics/gsl_statistics_ulong.h @@ -0,0 +1,75 @@ +/* statistics/gsl_statistics_ulong.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __GSL_STATISTICS_ULONG_H__ +#define __GSL_STATISTICS_ULONG_H__ + +#include <stddef.h> + +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +__BEGIN_DECLS + +double gsl_stats_ulong_mean (const unsigned long data[], const size_t stride, const size_t n); +double gsl_stats_ulong_variance (const unsigned long data[], const size_t stride, const size_t n); +double gsl_stats_ulong_sd (const unsigned long data[], const size_t stride, const size_t n); +double gsl_stats_ulong_variance_with_fixed_mean (const unsigned long data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_ulong_sd_with_fixed_mean (const unsigned long data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_ulong_absdev (const unsigned long data[], const size_t stride, const size_t n); +double gsl_stats_ulong_skew (const unsigned long data[], const size_t stride, const size_t n); +double gsl_stats_ulong_kurtosis (const unsigned long data[], const size_t stride, const size_t n); +double gsl_stats_ulong_lag1_autocorrelation (const unsigned long data[], const size_t stride, const size_t n); + +double gsl_stats_ulong_covariance (const unsigned long data1[], const size_t stride1,const unsigned long data2[], const size_t stride2, const size_t n); + +double gsl_stats_ulong_variance_m (const unsigned long data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_ulong_sd_m (const unsigned long data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_ulong_absdev_m (const unsigned long data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_ulong_skew_m_sd (const unsigned long data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_ulong_kurtosis_m_sd (const unsigned long data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_ulong_lag1_autocorrelation_m (const unsigned long data[], const size_t stride, const size_t n, const double mean); + +double gsl_stats_ulong_covariance_m (const unsigned long data1[], const size_t stride1,const unsigned long data2[], const size_t stride2, const size_t n, const double mean1, const double mean2); + + +double gsl_stats_ulong_pvariance (const unsigned long data1[], const size_t stride1, const size_t n1, const unsigned long data2[], const size_t stride2, const size_t n2); +double gsl_stats_ulong_ttest (const unsigned long data1[], const size_t stride1, const size_t n1, const unsigned long data2[], const size_t stride2, const size_t n2); + +unsigned long gsl_stats_ulong_max (const unsigned long data[], const size_t stride, const size_t n); +unsigned long gsl_stats_ulong_min (const unsigned long data[], const size_t stride, const size_t n); +void gsl_stats_ulong_minmax (unsigned long * min, unsigned long * max, const unsigned long data[], const size_t stride, const size_t n); + +size_t gsl_stats_ulong_max_index (const unsigned long data[], const size_t stride, const size_t n); +size_t gsl_stats_ulong_min_index (const unsigned long data[], const size_t stride, const size_t n); +void gsl_stats_ulong_minmax_index (size_t * min_index, size_t * max_index, const unsigned long data[], const size_t stride, const size_t n); + +double gsl_stats_ulong_median_from_sorted_data (const unsigned long sorted_data[], const size_t stride, const size_t n) ; +double gsl_stats_ulong_quantile_from_sorted_data (const unsigned long sorted_data[], const size_t stride, const size_t n, const double f) ; + +__END_DECLS + +#endif /* __GSL_STATISTICS_ULONG_H__ */ diff --git a/gsl-1.9/statistics/gsl_statistics_ushort.h b/gsl-1.9/statistics/gsl_statistics_ushort.h new file mode 100644 index 0000000..929be9e --- /dev/null +++ b/gsl-1.9/statistics/gsl_statistics_ushort.h @@ -0,0 +1,75 @@ +/* statistics/gsl_statistics_ushort.h + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __GSL_STATISTICS_USHORT_H__ +#define __GSL_STATISTICS_USHORT_H__ + +#include <stddef.h> + +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +__BEGIN_DECLS + +double gsl_stats_ushort_mean (const unsigned short data[], const size_t stride, const size_t n); +double gsl_stats_ushort_variance (const unsigned short data[], const size_t stride, const size_t n); +double gsl_stats_ushort_sd (const unsigned short data[], const size_t stride, const size_t n); +double gsl_stats_ushort_variance_with_fixed_mean (const unsigned short data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_ushort_sd_with_fixed_mean (const unsigned short data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_ushort_absdev (const unsigned short data[], const size_t stride, const size_t n); +double gsl_stats_ushort_skew (const unsigned short data[], const size_t stride, const size_t n); +double gsl_stats_ushort_kurtosis (const unsigned short data[], const size_t stride, const size_t n); +double gsl_stats_ushort_lag1_autocorrelation (const unsigned short data[], const size_t stride, const size_t n); + +double gsl_stats_ushort_covariance (const unsigned short data1[], const size_t stride1,const unsigned short data2[], const size_t stride2, const size_t n); + +double gsl_stats_ushort_variance_m (const unsigned short data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_ushort_sd_m (const unsigned short data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_ushort_absdev_m (const unsigned short data[], const size_t stride, const size_t n, const double mean); +double gsl_stats_ushort_skew_m_sd (const unsigned short data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_ushort_kurtosis_m_sd (const unsigned short data[], const size_t stride, const size_t n, const double mean, const double sd); +double gsl_stats_ushort_lag1_autocorrelation_m (const unsigned short data[], const size_t stride, const size_t n, const double mean); + +double gsl_stats_ushort_covariance_m (const unsigned short data1[], const size_t stride1,const unsigned short data2[], const size_t stride2, const size_t n, const double mean1, const double mean2); + + +double gsl_stats_ushort_pvariance (const unsigned short data1[], const size_t stride1, const size_t n1, const unsigned short data2[], const size_t stride2, const size_t n2); +double gsl_stats_ushort_ttest (const unsigned short data1[], const size_t stride1, const size_t n1, const unsigned short data2[], const size_t stride2, const size_t n2); + +unsigned short gsl_stats_ushort_max (const unsigned short data[], const size_t stride, const size_t n); +unsigned short gsl_stats_ushort_min (const unsigned short data[], const size_t stride, const size_t n); +void gsl_stats_ushort_minmax (unsigned short * min, unsigned short * max, const unsigned short data[], const size_t stride, const size_t n); + +size_t gsl_stats_ushort_max_index (const unsigned short data[], const size_t stride, const size_t n); +size_t gsl_stats_ushort_min_index (const unsigned short data[], const size_t stride, const size_t n); +void gsl_stats_ushort_minmax_index (size_t * min_index, size_t * max_index, const unsigned short data[], const size_t stride, const size_t n); + +double gsl_stats_ushort_median_from_sorted_data (const unsigned short sorted_data[], const size_t stride, const size_t n) ; +double gsl_stats_ushort_quantile_from_sorted_data (const unsigned short sorted_data[], const size_t stride, const size_t n, const double f) ; + +__END_DECLS + +#endif /* __GSL_STATISTICS_USHORT_H__ */ diff --git a/gsl-1.9/statistics/kurtosis.c b/gsl-1.9/statistics/kurtosis.c new file mode 100644 index 0000000..4d14f51 --- /dev/null +++ b/gsl-1.9/statistics/kurtosis.c @@ -0,0 +1,71 @@ +#include <config.h> +#include <math.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "kurtosis_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "kurtosis_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "kurtosis_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "kurtosis_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "kurtosis_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "kurtosis_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "kurtosis_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "kurtosis_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "kurtosis_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "kurtosis_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "kurtosis_source.c" +#include "templates_off.h" +#undef BASE_CHAR + + diff --git a/gsl-1.9/statistics/kurtosis_source.c b/gsl-1.9/statistics/kurtosis_source.c new file mode 100644 index 0000000..6260796 --- /dev/null +++ b/gsl-1.9/statistics/kurtosis_source.c @@ -0,0 +1,55 @@ +/* statistics/kurtosis_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +double +FUNCTION(gsl_stats,kurtosis) (const BASE data[], const size_t stride, const size_t n) +{ + const double mean = FUNCTION(gsl_stats,mean)(data, stride, n); + const double est_sd = FUNCTION(gsl_stats,sd_m)(data, stride, n, mean); + return FUNCTION(gsl_stats,kurtosis_m_sd)(data, stride, n, mean, est_sd); +} + +double +FUNCTION(gsl_stats,kurtosis_m_sd) (const BASE data[], + const size_t stride, + const size_t n, + const double mean, + const double sd) +{ + /* takes a dataset and finds the kurtosis */ + + long double avg = 0, kurtosis; + size_t i; + + /* find the fourth moment the deviations, normalized by the sd */ + + /* we use a recurrence relation to stably update a running value so + there aren't any large sums that can overflow */ + + for (i = 0; i < n; i++) + { + const long double x = (data[i * stride] - mean) / sd; + avg += (x * x * x * x - avg)/(i + 1); + } + + kurtosis = avg - 3.0; /* makes kurtosis zero for a Gaussian */ + + return kurtosis; +} + diff --git a/gsl-1.9/statistics/lag1.c b/gsl-1.9/statistics/lag1.c new file mode 100644 index 0000000..4bc09f1 --- /dev/null +++ b/gsl-1.9/statistics/lag1.c @@ -0,0 +1,70 @@ +#include <config.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "lag1_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "lag1_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "lag1_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "lag1_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "lag1_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "lag1_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "lag1_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "lag1_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "lag1_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "lag1_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "lag1_source.c" +#include "templates_off.h" +#undef BASE_CHAR + + diff --git a/gsl-1.9/statistics/lag1_source.c b/gsl-1.9/statistics/lag1_source.c new file mode 100644 index 0000000..117e6d8 --- /dev/null +++ b/gsl-1.9/statistics/lag1_source.c @@ -0,0 +1,51 @@ +/* statistics/lag1_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + + +double +FUNCTION(gsl_stats,lag1_autocorrelation) (const BASE data[], const size_t stride, const size_t n) +{ + const double mean = FUNCTION(gsl_stats,mean) (data, stride, n); + return FUNCTION(gsl_stats,lag1_autocorrelation_m)(data, stride, n, mean); +} + +double +FUNCTION(gsl_stats,lag1_autocorrelation_m) (const BASE data[], const size_t stride, const size_t size, const double mean) +{ + /* Compute the lag-1 autocorrelation of a dataset using the + recurrence relation */ + + size_t i; + + long double r1 ; + long double q = 0 ; + long double v = (data[0 * stride] - mean) * (data[0 * stride] - mean) ; + + for (i = 1; i < size ; i++) + { + const long double delta0 = (data[(i-1) * stride] - mean); + const long double delta1 = (data[i * stride] - mean); + q += (delta0 * delta1 - q)/(i + 1); + v += (delta1 * delta1 - v)/(i + 1); + } + + r1 = q / v ; + + return r1; +} diff --git a/gsl-1.9/statistics/mean.c b/gsl-1.9/statistics/mean.c new file mode 100644 index 0000000..24dd04f --- /dev/null +++ b/gsl-1.9/statistics/mean.c @@ -0,0 +1,70 @@ +#include <config.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "mean_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "mean_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "mean_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "mean_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "mean_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "mean_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "mean_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "mean_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "mean_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "mean_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "mean_source.c" +#include "templates_off.h" +#undef BASE_CHAR + + diff --git a/gsl-1.9/statistics/mean_source.c b/gsl-1.9/statistics/mean_source.c new file mode 100644 index 0000000..235d7bd --- /dev/null +++ b/gsl-1.9/statistics/mean_source.c @@ -0,0 +1,35 @@ +/* statistics/mean_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +double +FUNCTION (gsl_stats, mean) (const BASE data[], const size_t stride, const size_t size) +{ + /* Compute the arithmetic mean of a dataset using the recurrence relation + mean_(n) = mean(n-1) + (data[n] - mean(n-1))/(n+1) */ + + long double mean = 0; + size_t i; + + for (i = 0; i < size; i++) + { + mean += (data[i * stride] - mean) / (i + 1); + } + + return mean; +} diff --git a/gsl-1.9/statistics/median.c b/gsl-1.9/statistics/median.c new file mode 100644 index 0000000..e42301b --- /dev/null +++ b/gsl-1.9/statistics/median.c @@ -0,0 +1,71 @@ +#include <config.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "median_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "median_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "median_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "median_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "median_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "median_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "median_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "median_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "median_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "median_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "median_source.c" +#include "templates_off.h" +#undef BASE_CHAR + + + diff --git a/gsl-1.9/statistics/median_source.c b/gsl-1.9/statistics/median_source.c new file mode 100644 index 0000000..8ed1f65 --- /dev/null +++ b/gsl-1.9/statistics/median_source.c @@ -0,0 +1,44 @@ +/* statistics/median_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + + +double +FUNCTION(gsl_stats,median_from_sorted_data) (const BASE sorted_data[], + const size_t stride, + const size_t n) +{ + double median ; + const size_t lhs = (n - 1) / 2 ; + const size_t rhs = n / 2 ; + + if (n == 0) + return 0.0 ; + + if (lhs == rhs) + { + median = sorted_data[lhs * stride] ; + } + else + { + median = (sorted_data[lhs * stride] + sorted_data[rhs * stride])/2.0 ; + } + + return median ; +} + diff --git a/gsl-1.9/statistics/minmax.c b/gsl-1.9/statistics/minmax.c new file mode 100644 index 0000000..e3ce002 --- /dev/null +++ b/gsl-1.9/statistics/minmax.c @@ -0,0 +1,72 @@ +#include <config.h> +#include <stdlib.h> +#include <gsl/gsl_math.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "minmax_source.c" +#include "templates_off.h" +#undef BASE_CHAR + + diff --git a/gsl-1.9/statistics/minmax_source.c b/gsl-1.9/statistics/minmax_source.c new file mode 100644 index 0000000..2c52252 --- /dev/null +++ b/gsl-1.9/statistics/minmax_source.c @@ -0,0 +1,207 @@ +/* statistics/minmax_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + + +BASE +FUNCTION (gsl_stats,max) (const BASE data[], const size_t stride, + const size_t n) +{ + /* finds the largest member of a dataset */ + + BASE max = data[0 * stride]; + size_t i; + + for (i = 0; i < n; i++) + { + BASE xi = data[i * stride]; + + if (xi > max) + max = xi; +#ifdef FP + if (isnan (xi)) + return xi; +#endif + } + + return max; +} + +BASE +FUNCTION (gsl_stats,min) (const BASE data[], const size_t stride, + const size_t n) +{ + /* finds the smallest member of a dataset */ + + BASE min = data[0 * stride]; + size_t i; + + for (i = 0; i < n; i++) + { + BASE xi = data[i * stride]; + + if (xi < min) + min = xi; +#ifdef FP + if (isnan (xi)) + return xi; +#endif + } + + return min; + +} + +void +FUNCTION (gsl_stats,minmax) (BASE * min_out, BASE * max_out, + const BASE data[], const size_t stride, + const size_t n) +{ + /* finds the smallest and largest members of a dataset */ + + BASE min = data[0 * stride]; + BASE max = data[0 * stride]; + size_t i; + + for (i = 0; i < n; i++) + { + BASE xi = data[i * stride]; + + if (xi < min) + min = xi; + + if (xi > max) + max = xi; + +#ifdef FP + if (isnan (xi)) + { + min = xi; + max = xi; + break; + } +#endif + + } + + *min_out = min; + *max_out = max; +} + +size_t +FUNCTION (gsl_stats,max_index) (const BASE data[], const size_t stride, + const size_t n) +{ + /* finds the index of the largest member of a dataset */ + /* if there is more than one largest value then we choose the first */ + + BASE max = data[0 * stride]; + size_t i, max_index = 0; + + for (i = 0; i < n; i++) + { + BASE xi = data[i * stride]; + + if (xi > max) + { + max = xi; + max_index = i; + } + +#ifdef FP + if (isnan (xi)) + { + return i; + } +#endif + } + + return max_index; +} + +size_t +FUNCTION (gsl_stats,min_index) (const BASE data[], const size_t stride, + const size_t n) +{ + /* finds the index of the smallest member of a dataset */ + /* if there is more than one largest value then we choose the first */ + + BASE min = data[0 * stride]; + size_t i, min_index = 0; + + for (i = 0; i < n; i++) + { + BASE xi = data[i * stride]; + + if (xi < min) + { + min = xi; + min_index = i; + } + +#ifdef FP + if (isnan (xi)) + { + return i; + } +#endif + } + + return min_index; +} + +void +FUNCTION (gsl_stats,minmax_index) (size_t * min_index_out, + size_t * max_index_out, const BASE data[], + const size_t stride, const size_t n) +{ + /* finds the smallest and largest members of a dataset */ + + BASE min = data[0 * stride]; + BASE max = data[0 * stride]; + size_t i, min_index = 0, max_index = 0; + + for (i = 0; i < n; i++) + { + BASE xi = data[i * stride]; + + if (xi < min) + { + min = xi; + min_index = i; + } + + if (xi > max) + { + max = xi; + max_index = i; + } + +#ifdef FP + if (isnan (xi)) + { + min_index = i; + max_index = i; + break; + } +#endif + } + + *min_index_out = min_index; + *max_index_out = max_index; +} diff --git a/gsl-1.9/statistics/p_variance.c b/gsl-1.9/statistics/p_variance.c new file mode 100644 index 0000000..dafb43e --- /dev/null +++ b/gsl-1.9/statistics/p_variance.c @@ -0,0 +1,71 @@ +#include <config.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "p_variance_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "p_variance_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "p_variance_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "p_variance_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "p_variance_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "p_variance_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "p_variance_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "p_variance_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "p_variance_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "p_variance_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "p_variance_source.c" +#include "templates_off.h" +#undef BASE_CHAR + + + diff --git a/gsl-1.9/statistics/p_variance_source.c b/gsl-1.9/statistics/p_variance_source.c new file mode 100644 index 0000000..fe9b27a --- /dev/null +++ b/gsl-1.9/statistics/p_variance_source.c @@ -0,0 +1,39 @@ +/* statistics/p_variance_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + + +double +FUNCTION(gsl_stats,pvariance) (const BASE data1[], + const size_t stride1, const size_t n1, + const BASE data2[], + const size_t stride2, const size_t n2) +{ + /* Find the pooled variance of two datasets */ + + const double var1 = FUNCTION(gsl_stats,variance) (data1, stride1, n1); + const double var2 = FUNCTION(gsl_stats,variance) (data2, stride2, n2); + + /* calculate the pooled variance */ + + const double pooled_variance = + (((n1 - 1) * var1) + ((n2 - 1) * var2)) / (n1 + n2 - 2); + + return pooled_variance; +} + diff --git a/gsl-1.9/statistics/quantiles.c b/gsl-1.9/statistics/quantiles.c new file mode 100644 index 0000000..96a3a25 --- /dev/null +++ b/gsl-1.9/statistics/quantiles.c @@ -0,0 +1,71 @@ +#include <config.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "quantiles_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "quantiles_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "quantiles_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "quantiles_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "quantiles_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "quantiles_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "quantiles_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "quantiles_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "quantiles_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "quantiles_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "quantiles_source.c" +#include "templates_off.h" +#undef BASE_CHAR + + + diff --git a/gsl-1.9/statistics/quantiles_source.c b/gsl-1.9/statistics/quantiles_source.c new file mode 100644 index 0000000..393469d --- /dev/null +++ b/gsl-1.9/statistics/quantiles_source.c @@ -0,0 +1,45 @@ +/* statistics/quantiles_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + + +double +FUNCTION(gsl_stats,quantile_from_sorted_data) (const BASE sorted_data[], + const size_t stride, + const size_t n, + const double f) +{ + const double index = f * (n - 1) ; + const size_t lhs = (int)index ; + const double delta = index - lhs ; + double result; + + if (n == 0) + return 0.0 ; + + if (lhs == n - 1) + { + result = sorted_data[lhs * stride] ; + } + else + { + result = (1 - delta) * sorted_data[lhs * stride] + delta * sorted_data[(lhs + 1) * stride] ; + } + + return result ; +} diff --git a/gsl-1.9/statistics/skew.c b/gsl-1.9/statistics/skew.c new file mode 100644 index 0000000..00f379c --- /dev/null +++ b/gsl-1.9/statistics/skew.c @@ -0,0 +1,72 @@ +#include <config.h> +#include <math.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "skew_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "skew_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "skew_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "skew_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "skew_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "skew_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "skew_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "skew_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "skew_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "skew_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "skew_source.c" +#include "templates_off.h" +#undef BASE_CHAR + + + diff --git a/gsl-1.9/statistics/skew_source.c b/gsl-1.9/statistics/skew_source.c new file mode 100644 index 0000000..bbbca45 --- /dev/null +++ b/gsl-1.9/statistics/skew_source.c @@ -0,0 +1,51 @@ +/* statistics/skew_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +double +FUNCTION(gsl_stats,skew) (const BASE data[], const size_t stride, const size_t n) +{ + const double mean = FUNCTION(gsl_stats,mean)(data, stride, n); + const double sd = FUNCTION(gsl_stats,sd_m)(data, stride, n, mean); + return FUNCTION(gsl_stats,skew_m_sd)(data, stride, n, mean, sd); +} + +double +FUNCTION(gsl_stats,skew_m_sd) (const BASE data[], + const size_t stride, const size_t n, + const double mean, const double sd) +{ + /* takes a dataset and finds the skewness */ + + long double skew = 0; + size_t i; + + /* find the sum of the cubed deviations, normalized by the sd. */ + + /* we use a recurrence relation to stably update a running value so + there aren't any large sums that can overflow */ + + for (i = 0; i < n; i++) + { + const long double x = (data[i * stride] - mean) / sd; + skew += (x * x * x - skew) / (i + 1); + } + + return skew; +} + diff --git a/gsl-1.9/statistics/test.c b/gsl-1.9/statistics/test.c new file mode 100644 index 0000000..800fac4 --- /dev/null +++ b/gsl-1.9/statistics/test.c @@ -0,0 +1,132 @@ +/* statistics/test.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <config.h> +#include <string.h> +#include <stdlib.h> +#include <math.h> + +#include <gsl/gsl_math.h> +#include <gsl/gsl_test.h> +#include <gsl/gsl_sort.h> +#include <gsl/gsl_sort_vector.h> +#include <gsl/gsl_statistics.h> +#include <gsl/gsl_ieee_utils.h> + +int test_nist (void); + +/* Test program for mean.c. JimDavies 7.96 */ + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "test_float_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "test_float_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "test_float_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "test_int_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "test_int_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "test_int_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "test_int_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "test_int_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "test_int_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "test_int_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "test_int_source.c" +#include "templates_off.h" +#undef BASE_CHAR + + +int +main (void) +{ + size_t s1, s2; + + gsl_ieee_env_setup (); + + for (s1 = 1; s1 < 4 ; s1++) + { + s2 = (s1 < 3) ? 1 : (s1 - 1) ; + + test_func (s1,s2); + test_float_func (s1,s2); + test_long_double_func (s1,s2); + + test_ulong_func (s1,s2); + test_long_func (s1,s2); + test_uint_func (s1,s2); + test_int_func (s1,s2); + test_ushort_func (s1,s2); + test_short_func (s1,s2); + test_uchar_func (s1,s2); + test_char_func (s1,s2); + } + + test_nist(); + + exit (gsl_test_summary ()); +} + diff --git a/gsl-1.9/statistics/test_float_source.c b/gsl-1.9/statistics/test_float_source.c new file mode 100644 index 0000000..7b29dfa --- /dev/null +++ b/gsl-1.9/statistics/test_float_source.c @@ -0,0 +1,382 @@ +/* statistics/test_float_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +void FUNCTION (test, func) (const size_t stridea, const size_t strideb); + +void +FUNCTION (test, func) (const size_t stridea, const size_t strideb) +{ + /* sample sets of doubles */ + size_t i; + const size_t na = 14, nb = 14; + + const double rawa[] = + {.0421, .0941, .1064, .0242, .1331, + .0773, .0243, .0815, .1186, .0356, + .0728, .0999, .0614, .0479}; + + const double rawb[] = + {.1081, .0986, .1566, .1961, .1125, + .1942, .1079, .1021, .1583, .1673, + .1675, .1856, .1688, .1512}; + + const double raww[] = + {.0000, .0000, .0000, 3.000, .0000, + 1.000, 1.000, 1.000, 0.000, .5000, + 7.000, 5.000, 4.000, 0.123}; + + BASE * sorted ; + + BASE * groupa = (BASE *) malloc (stridea * na * sizeof(BASE)); + BASE * groupb = (BASE *) malloc (strideb * nb * sizeof(BASE)); + BASE * w = (BASE *) malloc (strideb * na * sizeof(BASE)); + +#ifdef BASE_FLOAT + double rel = 1e-6; +#else + double rel = 1e-10; +#endif + + for (i = 0 ; i < na ; i++) + groupa[i * stridea] = (BASE) rawa[i] ; + + for (i = 0 ; i < na ; i++) + w[i * strideb] = (BASE) raww[i] ; + + for (i = 0 ; i < nb ; i++) + groupb[i * strideb] = (BASE) rawb[i] ; + + + { + double mean = FUNCTION(gsl_stats,mean) (groupa, stridea, na); + double expected = 0.0728; + gsl_test_rel (mean, expected, rel, NAME(gsl_stats) "_mean"); + } + + { + double mean = FUNCTION(gsl_stats,mean) (groupa, stridea, na); + double var = FUNCTION(gsl_stats,variance_with_fixed_mean) (groupa, stridea, na, mean); + double expected = 0.00113837428571429; + gsl_test_rel (var, expected, rel, NAME(gsl_stats) "_variance_with_fixed_mean"); + } + + + { + double mean = FUNCTION(gsl_stats,mean) (groupa, stridea, na); + double var = FUNCTION(gsl_stats,sd_with_fixed_mean) (groupa, stridea, na, mean); + double expected = 0.0337398026922845; + gsl_test_rel (var, expected, rel, NAME(gsl_stats) "_sd_with_fixed_mean"); + } + + + { + double var = FUNCTION(gsl_stats,variance) (groupb, strideb, nb); + double expected = 0.00124956615384615; + gsl_test_rel (var, expected, rel, NAME(gsl_stats) "_variance"); + } + + { + double sd = FUNCTION(gsl_stats,sd) (groupa, stridea, na); + double expected = 0.0350134479659107; + gsl_test_rel (sd, expected, rel, NAME(gsl_stats) "_sd"); + } + + { + double absdev = FUNCTION(gsl_stats,absdev) (groupa, stridea, na); + double expected = 0.0287571428571429; + gsl_test_rel (absdev, expected, rel, NAME(gsl_stats) "_absdev"); + } + + { + double skew = FUNCTION(gsl_stats,skew) (groupa, stridea, na); + double expected = 0.0954642051479004; + gsl_test_rel (skew, expected, rel, NAME(gsl_stats) "_skew"); + } + + { + double kurt = FUNCTION(gsl_stats,kurtosis) (groupa, stridea, na); + double expected = -1.38583851548909 ; + gsl_test_rel (kurt, expected, rel, NAME(gsl_stats) "_kurtosis"); + } + + { + double wmean = FUNCTION(gsl_stats,wmean) (w, strideb, groupa, stridea, na); + double expected = 0.0678111523670601; + gsl_test_rel (wmean, expected, rel, NAME(gsl_stats) "_wmean"); + } + + { + double wmean = FUNCTION(gsl_stats,wmean) (w, strideb, groupa, stridea, na); + double wvar = FUNCTION(gsl_stats,wvariance_with_fixed_mean) (w, strideb, groupa, stridea, na, wmean); + double expected = 0.000615793060878654; + gsl_test_rel (wvar, expected, rel, NAME(gsl_stats) "_wvariance_with_fixed_mean"); + } + + { + double est_wvar = FUNCTION(gsl_stats,wvariance) (w, strideb, groupa, stridea, na); + double expected = 0.000769562962860317; + gsl_test_rel (est_wvar, expected, rel, NAME(gsl_stats) "_wvariance"); + } + + { + double wsd = FUNCTION(gsl_stats,wsd) (w, strideb, groupa, stridea, na); + double expected = 0.0277409978706664; + gsl_test_rel (wsd, expected, rel, NAME(gsl_stats) "_wsd"); + } + + { + double wabsdev = FUNCTION(gsl_stats,wabsdev) (w, strideb, groupa, stridea, na); + double expected = 0.0193205027504008; + gsl_test_rel (wabsdev, expected, rel, NAME(gsl_stats) "_wabsdev"); + } + + { + double wskew = FUNCTION(gsl_stats,wskew) (w, strideb, groupa, stridea, na); + double expected = -0.373631000307076; + gsl_test_rel (wskew, expected, rel, NAME(gsl_stats) "_wskew"); + } + + { + double wkurt = FUNCTION(gsl_stats,wkurtosis) (w, strideb, groupa, stridea, na); + double expected = -1.48114233353963; + gsl_test_rel (wkurt, expected, rel, NAME(gsl_stats) "_wkurtosis"); + } + + { + double c = FUNCTION(gsl_stats,covariance) (groupa, stridea, groupb, strideb, nb); + double expected = -0.000139021538461539; + gsl_test_rel (c, expected, rel, NAME(gsl_stats) "_covariance"); + } + + + { + double pv = FUNCTION(gsl_stats,pvariance) (groupa, stridea, na, groupb, strideb, nb); + double expected = 0.00123775384615385; + gsl_test_rel (pv, expected, rel, NAME(gsl_stats) "_pvariance"); + } + + { + double t = FUNCTION(gsl_stats,ttest) (groupa, stridea, na, groupb, strideb, nb); + double expected = -5.67026326985851; + gsl_test_rel (t, expected, rel, NAME(gsl_stats) "_ttest"); + } + + { + BASE expected = (BASE)0.1331; + gsl_test (FUNCTION(gsl_stats,max) (groupa, stridea, na) != expected, + NAME(gsl_stats) "_max (" OUT_FORMAT " observed vs " OUT_FORMAT " expected)", + FUNCTION(gsl_stats,max) (groupa, stridea, na), expected); + } + + { + BASE min = FUNCTION(gsl_stats,min) (groupa, stridea, na); + BASE expected = (BASE)0.0242; + gsl_test (min != expected, + NAME(gsl_stats) "_min (" OUT_FORMAT " observed vs " OUT_FORMAT " expected)", + min, expected); + } + + { + BASE min, max; + BASE expected_max = (BASE)0.1331; + BASE expected_min = (BASE)0.0242; + + FUNCTION(gsl_stats,minmax) (&min, &max, groupa, stridea, na); + + gsl_test (max != expected_max, + NAME(gsl_stats) "_minmax max (" OUT_FORMAT " observed vs " OUT_FORMAT " expected)", + max, expected_max); + gsl_test (min != expected_min, + NAME(gsl_stats) "_minmax min (" OUT_FORMAT " observed vs " OUT_FORMAT " expected)", + min, expected_min); + } + + { + int max_index = FUNCTION(gsl_stats,max_index) (groupa, stridea, na); + int expected = 4; + gsl_test (max_index != expected, + NAME(gsl_stats) "_max_index (%d observed vs %d expected)", + max_index, expected); + } + + { + int min_index = FUNCTION(gsl_stats,min_index) (groupa, stridea, na); + int expected = 3; + gsl_test (min_index != expected, + NAME(gsl_stats) "_min_index (%d observed vs %d expected)", + min_index, expected); + } + + { + size_t min_index, max_index; + size_t expected_max_index = 4; + size_t expected_min_index = 3; + + FUNCTION(gsl_stats,minmax_index) (&min_index, &max_index, groupa, stridea, na); + + gsl_test (max_index != expected_max_index, + NAME(gsl_stats) "_minmax_index max (%u observed vs %u expected)", + max_index, expected_max_index); + gsl_test (min_index != expected_min_index, + NAME(gsl_stats) "_minmax_index min (%u observed vs %u expected)", + min_index, expected_min_index); + } + + + sorted = (BASE *) malloc(stridea * na * sizeof(BASE)) ; + + for (i = 0 ; i < na ; i++) + sorted[stridea * i] = groupa[stridea * i] ; + + TYPE(gsl_sort)(sorted, stridea, na) ; + + { + double median = FUNCTION(gsl_stats,median_from_sorted_data)(sorted, stridea, na) ; + double expected = 0.07505; + gsl_test_rel (median,expected, rel, + NAME(gsl_stats) "_median_from_sorted_data (even)"); + } + + { + double median = FUNCTION(gsl_stats,median_from_sorted_data)(sorted, stridea, na - 1) ; + double expected = 0.0728; + gsl_test_rel (median,expected, rel, + NAME(gsl_stats) "_median_from_sorted_data"); + } + + + { + double zeroth = FUNCTION(gsl_stats,quantile_from_sorted_data)(sorted, stridea, na, 0.0) ; + double expected = 0.0242; + gsl_test_rel (zeroth,expected, rel, + NAME(gsl_stats) "_quantile_from_sorted_data (0)"); + } + + { + double top = FUNCTION(gsl_stats,quantile_from_sorted_data)(sorted, stridea, na, 1.0) ; + double expected = 0.1331; + gsl_test_rel (top,expected, rel, + NAME(gsl_stats) "_quantile_from_sorted_data (100)"); + } + + { + double median = FUNCTION(gsl_stats,quantile_from_sorted_data)(sorted, stridea, na, 0.5) ; + double expected = 0.07505; + gsl_test_rel (median,expected, rel, + NAME(gsl_stats) "_quantile_from_sorted_data (50even)"); + } + + { + double median = FUNCTION(gsl_stats,quantile_from_sorted_data)(sorted, stridea, na - 1, 0.5); + double expected = 0.0728; + gsl_test_rel (median,expected, rel, + NAME(gsl_stats) "_quantile_from_sorted_data (50odd)"); + + } + + /* Test for IEEE handling - set third element to NaN */ + + groupa [3*stridea] = GSL_NAN; + + { + BASE max = FUNCTION(gsl_stats,max) (groupa, stridea, na); + BASE expected = GSL_NAN; + gsl_test (!isnan(max), + NAME(gsl_stats) "_max NaN (" OUT_FORMAT " observed vs " OUT_FORMAT " expected)", + max, expected); + } + + { + BASE min = FUNCTION(gsl_stats,min) (groupa, stridea, na); + BASE expected = GSL_NAN; + gsl_test (!isnan(min), + NAME(gsl_stats) "_min NaN (" OUT_FORMAT " observed vs " OUT_FORMAT " expected)", + min, expected); + } + + { + BASE min, max; + BASE expected_max = GSL_NAN; + BASE expected_min = GSL_NAN; + + FUNCTION(gsl_stats,minmax) (&min, &max, groupa, stridea, na); + + gsl_test (!isnan(max), + NAME(gsl_stats) "_minmax max NaN (" OUT_FORMAT " observed vs " OUT_FORMAT " expected)", + max, expected_max); + gsl_test (!isnan(min), + NAME(gsl_stats) "_minmax min NaN (" OUT_FORMAT " observed vs " OUT_FORMAT " expected)", + min, expected_min); + } + +#ifdef FAST + { + BASE min, max; + BASE expected_max = GSL_NAN; + BASE expected_min = GSL_NAN; + + FUNCTION(gsl_stats,minmax) (&min, &max, groupa, stridea, na-1); + + gsl_test (!isnan(max), + NAME(gsl_stats) "_minmax(-1) max NaN (" OUT_FORMAT " observed vs " OUT_FORMAT " expected)", + max, expected_max); + gsl_test (!isnan(min), + NAME(gsl_stats) "_minmax(-1) min NaN (" OUT_FORMAT " observed vs " OUT_FORMAT " expected)", + min, expected_min); + } +#endif + + + { + int max_index = FUNCTION(gsl_stats,max_index) (groupa, stridea, na); + int expected = 3; + gsl_test (max_index != expected, + NAME(gsl_stats) "_max_index NaN (%d observed vs %d expected)", + max_index, expected); + } + + { + int min_index = FUNCTION(gsl_stats,min_index) (groupa, stridea, na); + int expected = 3; + gsl_test (min_index != expected, + NAME(gsl_stats) "_min_index NaN (%d observed vs %d expected)", + min_index, expected); + } + + { + size_t min_index, max_index; + size_t expected_max_index = 3; + size_t expected_min_index = 3; + + FUNCTION(gsl_stats,minmax_index) (&min_index, &max_index, groupa, stridea, na); + + gsl_test (max_index != expected_max_index, + NAME(gsl_stats) "_minmax_index max NaN (%u observed vs %u expected)", + max_index, expected_max_index); + gsl_test (min_index != expected_min_index, + NAME(gsl_stats) "_minmax_index min NaN (%u observed vs %u expected)", + min_index, expected_min_index); + } + + free (sorted); + free (groupa); + free (groupb); + free (w); + +} diff --git a/gsl-1.9/statistics/test_int_source.c b/gsl-1.9/statistics/test_int_source.c new file mode 100644 index 0000000..1441f0b --- /dev/null +++ b/gsl-1.9/statistics/test_int_source.c @@ -0,0 +1,253 @@ +/* statistics/test_int_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +void FUNCTION (test, func) (const size_t stridea, const size_t strideb); + +void +FUNCTION (test, func) (const size_t stridea, const size_t strideb) +{ + /* sample sets of integers */ + size_t i; + const size_t ina = 20, inb = 20; + + const BASE raw1[] = {1, 2, 3, 4, 5, 6} ; + + const BASE irawa[] = + {17, 18, 16, 18, 12, + 20, 18, 20, 20, 22, + 20, 10, 8, 12, 16, + 16, 18, 20, 18, 21}; + + const BASE irawb[] = + {19, 20, 22, 24, 10, + 25, 20, 22, 21, 23, + 20, 10, 12, 14, 12, + 20, 22, 24, 23, 17}; + + BASE * sorted ; + + BASE * test1 = (BASE *) malloc (stridea * 6 * sizeof(BASE)); + BASE * igroupa = (BASE *) malloc (stridea * ina * sizeof(BASE)); + BASE * igroupb = (BASE *) malloc (strideb * inb * sizeof(BASE)); + + double rel = 1e-10 ; + + for (i = 0 ; i < ina ; i++) + igroupa[i * stridea] = irawa[i] ; + + for (i = 0 ; i < inb ; i++) + igroupb[i * strideb] = irawb[i] ; + + for (i = 0 ; i < 6 ; i++) + test1[i * stridea] = raw1[i] ; + + + + { + double mean = FUNCTION(gsl_stats,mean) (igroupa, stridea, ina); + double expected = 17.0; + gsl_test_rel (mean,expected, rel, NAME(gsl_stats) "_mean (integer)"); + } + + { + double mean = FUNCTION(gsl_stats,mean) (test1, stridea, 6); + double expected = 3.5; + gsl_test_rel (mean,expected, rel, NAME(gsl_stats) "_mean (fractional)"); + } + + { + double mean = FUNCTION(gsl_stats,mean) (igroupa, stridea, ina); + double var = FUNCTION(gsl_stats,variance_with_fixed_mean) (igroupa, stridea, ina, mean); + double expected = 13.7; + gsl_test_rel (var, expected, rel, NAME(gsl_stats) "_variance_with_fixed_mean"); + } + + { + double mean = FUNCTION(gsl_stats,mean) (igroupa, stridea, ina); + double sd = FUNCTION(gsl_stats,sd_with_fixed_mean) (igroupa, stridea, ina, mean); + double expected = 3.70135110466435; + gsl_test_rel (sd, expected, rel, NAME(gsl_stats) "_sd_with_fixed_mean"); + } + + { + double var = FUNCTION(gsl_stats,variance) (igroupa, stridea, ina); + double expected = 14.4210526315789; + gsl_test_rel (var, expected, rel, NAME(gsl_stats) "_variance"); + } + + { + double sd_est = FUNCTION(gsl_stats,sd) (igroupa, stridea, ina); + double expected = 3.79750610685209; + gsl_test_rel (sd_est, expected, rel, NAME(gsl_stats) "_sd"); + } + + { + double absdev = FUNCTION(gsl_stats,absdev) (igroupa, stridea, ina); + double expected = 2.9; + gsl_test_rel (absdev, expected, rel, NAME(gsl_stats) "_absdev"); + } + + { + double skew = FUNCTION(gsl_stats,skew) (igroupa, stridea, ina); + double expected = -0.909355923168064; + gsl_test_rel (skew, expected, rel, NAME(gsl_stats) "_skew"); + } + + { + double kurt = FUNCTION(gsl_stats,kurtosis) (igroupa, stridea, ina); + double expected = -0.233692524908094 ; + gsl_test_rel (kurt, expected, rel, NAME(gsl_stats) "_kurtosis"); + } + + { + double c = FUNCTION(gsl_stats,covariance) (igroupa, stridea, igroupb, strideb, inb); + double expected = 14.5263157894737; + gsl_test_rel (c, expected, rel, NAME(gsl_stats) "_covariance"); + } + + + { + double pv = FUNCTION(gsl_stats,pvariance) (igroupa, stridea, ina, igroupb, strideb, inb); + double expected = 18.8421052631579; + gsl_test_rel (pv, expected, rel, NAME(gsl_stats) "_pvariance"); + } + + { + double t = FUNCTION(gsl_stats,ttest) (igroupa, stridea, ina, igroupb, strideb, inb); + double expected = -1.45701922702927; + gsl_test_rel (t, expected, rel, NAME(gsl_stats) "_ttest"); + } + + { + int max = FUNCTION(gsl_stats,max) (igroupa, stridea, ina); + int expected = 22; + gsl_test (max != expected, + NAME(gsl_stats) "_max (%d observed vs %d expected)", max, expected); + } + + { + int min = FUNCTION(gsl_stats,min) (igroupa, stridea, ina); + int expected = 8; + gsl_test (min != expected, + NAME(gsl_stats) "_min (%d observed vs %d expected)", min, expected); + } + + { + BASE min, max; + BASE expected_max = 22; + BASE expected_min = 8; + + FUNCTION(gsl_stats,minmax) (&min, &max, igroupa, stridea, ina); + + gsl_test (max != expected_max, + NAME(gsl_stats) "_minmax max (" OUT_FORMAT " observed vs " OUT_FORMAT " expected)", + max, expected_max); + gsl_test (min != expected_min, + NAME(gsl_stats) "_minmax min (" OUT_FORMAT " observed vs " OUT_FORMAT " expected)", + min, expected_min); + } + + { + int max_index = FUNCTION(gsl_stats,max_index) (igroupa, stridea, ina); + int expected = 9 ; + gsl_test (max_index != expected, + NAME(gsl_stats) "_max_index (%d observed vs %d expected)", + max_index, expected); + } + + { + int min_index = FUNCTION(gsl_stats,min_index) (igroupa, stridea, ina); + int expected = 12 ; + gsl_test (min_index != expected, + NAME(gsl_stats) "_min_index (%d observed vs %d expected)", + min_index, expected); + } + + { + size_t min_index, max_index; + size_t expected_max_index = 9; + size_t expected_min_index = 12; + + FUNCTION(gsl_stats,minmax_index) (&min_index, &max_index, igroupa, stridea, ina); + + gsl_test (max_index != expected_max_index, + NAME(gsl_stats) "_minmax_index max (%u observed vs %u expected)", + max_index, expected_max_index); + gsl_test (min_index != expected_min_index, + NAME(gsl_stats) "_minmax_index min (%u observed vs %u expected)", + min_index, expected_min_index); + } + + + sorted = (BASE *) malloc(stridea * ina * sizeof(BASE)) ; + + for (i = 0 ; i < ina ; i++) + sorted[stridea * i] = igroupa[stridea * i] ; + + + TYPE(gsl_sort)(sorted, stridea, ina) ; + + { + double median = FUNCTION(gsl_stats,median_from_sorted_data)(sorted, stridea, ina) ; + double expected = 18; + gsl_test_rel (median,expected, rel, + NAME(gsl_stats) "_median_from_sorted_data (even)"); + } + + { + double median = FUNCTION(gsl_stats,median_from_sorted_data)(sorted, stridea, ina - 1) ; + double expected = 18; + gsl_test_rel (median,expected, rel, + NAME(gsl_stats) "_median_from_sorted_data (odd)"); + } + + + { + double zeroth = FUNCTION(gsl_stats,quantile_from_sorted_data)(sorted, stridea, ina, 0.0) ; + double expected = 8; + gsl_test_rel (zeroth,expected, rel, + NAME(gsl_stats) "_quantile_from_sorted_data (0)"); + } + + { + double top = FUNCTION(gsl_stats,quantile_from_sorted_data)(sorted, stridea, ina, 1.0) ; + double expected = 22; + gsl_test_rel (top,expected, rel, + NAME(gsl_stats) "_quantile_from_sorted_data (100)"); + } + + { + double median = FUNCTION(gsl_stats,quantile_from_sorted_data)(sorted, stridea, ina, 0.5) ; + double expected = 18; + gsl_test_rel (median,expected, rel, + NAME(gsl_stats) "_quantile_from_sorted_data (50, even)"); + } + + { + double median = FUNCTION(gsl_stats,quantile_from_sorted_data)(sorted, stridea, ina - 1, 0.5); + double expected = 18; + gsl_test_rel (median,expected, rel, + NAME(gsl_stats) "_quantile_from_sorted_data (50, odd)"); + } + + free (sorted); + free (igroupa); + free (igroupb); + free (test1); +} diff --git a/gsl-1.9/statistics/test_nist.c b/gsl-1.9/statistics/test_nist.c new file mode 100644 index 0000000..5c5180d --- /dev/null +++ b/gsl-1.9/statistics/test_nist.c @@ -0,0 +1,503 @@ +/* statistics/test_nist.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* These tests are based on the NIST Statistical Reference Datasets + See http://www.nist.gov/itl/div898/strd/index.html for more + information. */ + +#include <config.h> +#include <stdlib.h> +#include <math.h> + +#include <gsl/gsl_test.h> +#include <gsl/gsl_statistics.h> +#include <gsl/gsl_ieee_utils.h> + +int +test_nist (void) +{ + size_t i ; + + const size_t nlew = 200 ; + + const double lew[200] = { + -213, -564, -35, -15, 141, 115, -420, -360, 203, -338, -431, 194, + -220, -513, 154, -125, -559, 92, -21, -579, -52, 99, -543, -175, + 162, -457, -346, 204, -300, -474, 164, -107, -572, -8, 83, -541, + -224, 180, -420, -374, 201, -236, -531, 83, 27, -564, -112, 131, + -507, -254, 199, -311, -495, 143, -46, -579, -90, 136, -472, -338, + 202, -287, -477, 169, -124, -568, 17, 48, -568, -135, 162, -430, + -422, 172, -74, -577, -13, 92, -534, -243, 194, -355, -465, 156, + -81, -578, -64, 139, -449, -384, 193, -198, -538, 110, -44, -577, + -6, 66, -552, -164, 161, -460, -344, 205, -281, -504, 134, -28, + -576, -118, 156, -437, -381, 200, -220, -540, 83, 11, -568, -160, + 172, -414, -408, 188, -125, -572, -32, 139, -492, -321, 205, -262, + -504, 142, -83, -574, 0, 48, -571, -106, 137, -501, -266, 190, + -391, -406, 194, -186, -553, 83, -13, -577, -49, 103, -515, -280, + 201, 300, -506, 131, -45, -578, -80, 138, -462, -361, 201, -211, + -554, 32, 74, -533, -235, 187, -372, -442, 182, -147, -566, 25, + 68, -535, -244, 194, -351, -463, 174, -125, -570, 15, 72, -550, + -190, 172, -424, -385, 198, -218, -536, 96 } ; + + const size_t nlottery = 218 ; + + const double lottery[218] = { + 162, 671, 933, 414, 788, 730, 817, 33, 536, 875, 670, 236, 473, 167, + 877, 980, 316, 950, 456, 92, 517, 557, 956, 954, 104, 178, 794, 278, + 147, 773, 437, 435, 502, 610, 582, 780, 689, 562, 964, 791, 28, 97, + 848, 281, 858, 538, 660, 972, 671, 613, 867, 448, 738, 966, 139, 636, + 847, 659, 754, 243, 122, 455, 195, 968, 793, 59, 730, 361, 574, 522, + 97, 762, 431, 158, 429, 414, 22, 629, 788, 999, 187, 215, 810, 782, + 47, 34, 108, 986, 25, 644, 829, 630, 315, 567, 919, 331, 207, 412, + 242, 607, 668, 944, 749, 168, 864, 442, 533, 805, 372, 63, 458, 777, + 416, 340, 436, 140, 919, 350, 510, 572, 905, 900, 85, 389, 473, 758, + 444, 169, 625, 692, 140, 897, 672, 288, 312, 860, 724, 226, 884, 508, + 976, 741, 476, 417, 831, 15, 318, 432, 241, 114, 799, 955, 833, 358, + 935, 146, 630, 830, 440, 642, 356, 373, 271, 715, 367, 393, 190, 669, + 8, 861, 108, 795, 269, 590, 326, 866, 64, 523, 862, 840, 219, 382, + 998, 4, 628, 305, 747, 247, 34, 747, 729, 645, 856, 974, 24, 568, 24, + 694, 608, 480, 410, 729, 947, 293, 53, 930, 223, 203, 677, 227, 62, + 455, 387, 318, 562, 242, 428, 968 } ; + + const size_t nmavro = 50 ; + + const double mavro[50] = { + 2.00180, 2.00170, 2.00180, 2.00190, 2.00180, 2.00170, 2.00150, + 2.00140, 2.00150, 2.00150, 2.00170, 2.00180, 2.00180, 2.00190, + 2.00190, 2.00210, 2.00200, 2.00160, 2.00140, 2.00130, 2.00130, + 2.00150, 2.00150, 2.00160, 2.00150, 2.00140, 2.00130, 2.00140, + 2.00150, 2.00140, 2.00150, 2.00160, 2.00150, 2.00160, 2.00190, + 2.00200, 2.00200, 2.00210, 2.00220, 2.00230, 2.00240, 2.00250, + 2.00270, 2.00260, 2.00260, 2.00260, 2.00270, 2.00260, 2.00250, + 2.00240 } ; + + const size_t nmichelson = 100 ; + + const double michelson [100] = { + 299.85, 299.74, 299.90, 300.07, 299.93, 299.85, 299.95, 299.98, + 299.98, 299.88, 300.00, 299.98, 299.93, 299.65, 299.76, 299.81, + 300.00, 300.00, 299.96, 299.96, 299.96, 299.94, 299.96, 299.94, + 299.88, 299.80, 299.85, 299.88, 299.90, 299.84, 299.83, 299.79, + 299.81, 299.88, 299.88, 299.83, 299.80, 299.79, 299.76, 299.80, + 299.88, 299.88, 299.88, 299.86, 299.72, 299.72, 299.62, 299.86, + 299.97, 299.95, 299.88, 299.91, 299.85, 299.87, 299.84, 299.84, + 299.85, 299.84, 299.84, 299.84, 299.89, 299.81, 299.81, 299.82, + 299.80, 299.77, 299.76, 299.74, 299.75, 299.76, 299.91, 299.92, + 299.89, 299.86, 299.88, 299.72, 299.84, 299.85, 299.85, 299.78, + 299.89, 299.84, 299.78, 299.81, 299.76, 299.81, 299.79, 299.81, + 299.82, 299.85, 299.87, 299.87, 299.81, 299.74, 299.81, 299.94, + 299.95, 299.80, 299.81, 299.87 } ; + + const size_t npidigits = 5000 ; + const double pidigits [5000] = { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, + 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, + 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9,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8, 8, 0, 0, 7, 8, 6, 9, 2, 5, 6, + 0, 2, 9, 0, 2, 2, 8, 4, 7, 2, 1, 0, 4, 0, 3, 1, 7, 2, 1, 1, 8, 6, + 0, 8, 2, 0, 4, 1, 9, 0, 0, 0, 4, 2, 2, 9, 6, 6, 1, 7, 1, 1, 9, 6, + 3, 7, 7, 9, 2, 1, 3, 3, 7, 5, 7, 5, 1, 1, 4, 9, 5, 9, 5, 0, 1, 5, + 6, 6, 0, 4, 9, 6, 3, 1, 8, 6, 2, 9, 4, 7, 2, 6, 5, 4, 7, 3, 6, 4, + 2, 5, 2, 3, 0, 8, 1, 7, 7, 0, 3, 6, 7, 5, 1, 5, 9, 0, 6, 7, 3, 5, + 0, 2, 3, 5, 0, 7, 2, 8, 3, 5, 4, 0, 5, 6, 7, 0, 4, 0, 3, 8, 6, 7, + 4, 3, 5, 1, 3, 6, 2, 2, 2, 2, 4, 7, 7, 1, 5, 8, 9, 1, 5, 0, 4, 9, + 5, 3, 0, 9, 8, 4, 4, 4, 8, 9, 3, 3, 3, 0, 9, 6, 3, 4, 0, 8, 7, 8, + 0, 7, 6, 9, 3, 2, 5, 9, 9, 3, 9, 7, 8, 0, 5, 4, 1, 9, 3, 4, 1, 4, + 4, 7, 3, 7, 7, 4, 4, 1, 8, 4, 2, 6, 3, 1, 2, 9, 8, 6, 0, 8, 0, 9, + 9, 8, 8, 8, 6, 8, 7, 4, 1, 3, 2, 6, 0, 4, 7, 2 } ; + + + const size_t nacc1 = 3 ; + const double numacc1[3] = { 10000001, 10000003, 10000002 } ; + + const size_t nacc2 = 1001 ; + double numacc2[1001] ; + + const size_t nacc3 = 1001 ; + double numacc3[1001] ; + + const size_t nacc4 = 1001 ; + double numacc4[1001] ; + + numacc2[0] = 1.2 ; + numacc3[0] = 1000000.2 ; + numacc4[0] = 10000000.2 ; + + for (i = 1 ; i < 1000 ; i += 2) + { + numacc2[i] = 1.1 ; + numacc2[i+1] = 1.3 ; + numacc3[i] = 1000000.1 ; + numacc3[i+1] = 1000000.3 ; + numacc4[i] = 10000000.1 ; + numacc4[i+1] = 10000000.3 ; + } + + gsl_ieee_env_setup (); + + { + double mean = gsl_stats_mean (lew, 1, nlew); + double sd = gsl_stats_sd (lew, 1, nlew); + double lag1 = gsl_stats_lag1_autocorrelation (lew, 1, nlew); + + double expected_mean = -177.435000000000; + double expected_sd = 277.332168044316; + double expected_lag1 = -0.307304800605679; + + gsl_test_rel (mean, expected_mean, 1e-15, "lew gsl_stats_mean") ; + gsl_test_rel (sd, expected_sd, 1e-15, "lew gsl_stats_sd") ; + gsl_test_rel (lag1, expected_lag1, 1e-14, "lew autocorrelation") ; + } + + + { + double mean = gsl_stats_mean (lottery, 1, nlottery); + double sd = gsl_stats_sd (lottery, 1, nlottery); + double lag1 = gsl_stats_lag1_autocorrelation (lottery, 1, nlottery); + + double expected_mean = 518.958715596330; + double expected_sd = 291.699727470969; + double expected_lag1 = -0.120948622967393; + + gsl_test_rel (mean, expected_mean, 1e-15, "lottery gsl_stats_mean") ; + gsl_test_rel (sd, expected_sd, 1e-15, "lottery gsl_stats_sd") ; + gsl_test_rel (lag1, expected_lag1, 1e-14, "lottery autocorrelation") ; + } + + { + double mean = gsl_stats_mean (mavro, 1, nmavro); + double sd = gsl_stats_sd (mavro, 1, nmavro); + double lag1 = gsl_stats_lag1_autocorrelation (mavro, 1, nmavro); + + double expected_mean = 2.00185600000000; + double expected_sd = 0.000429123454003053; + double expected_lag1 = 0.937989183438248; + + gsl_test_rel (mean, expected_mean, 1e-15, "mavro gsl_stats_mean") ; + gsl_test_rel (sd, expected_sd, 1e-13, "mavro gsl_stats_sd") ; + gsl_test_rel (lag1, expected_lag1, 1e-13, "mavro autocorrelation") ; + } + + + { + double mean = gsl_stats_mean (michelson, 1, nmichelson); + double sd = gsl_stats_sd (michelson, 1, nmichelson); + double lag1 = gsl_stats_lag1_autocorrelation (michelson, 1, nmichelson); + + double expected_mean = 299.852400000000; + double expected_sd = 0.0790105478190518; + double expected_lag1 = 0.535199668621283; + + gsl_test_rel (mean, expected_mean, 1e-15, "michelson gsl_stats_mean") ; + gsl_test_rel (sd, expected_sd, 1e-13, "michelson gsl_stats_sd") ; + gsl_test_rel (lag1, expected_lag1, 1e-13, "michelson autocorrelation") ; + } + + { + double mean = gsl_stats_mean (pidigits, 1, npidigits); + double sd = gsl_stats_sd (pidigits, 1, npidigits); + double lag1 = gsl_stats_lag1_autocorrelation (pidigits, 1, npidigits); + + double expected_mean = 4.53480000000000; + double expected_sd = 2.86733906028871; + double expected_lag1 = -0.00355099287237972; + + gsl_test_rel (mean, expected_mean, 1e-14, "pidigits gsl_stats_mean") ; + gsl_test_rel (sd, expected_sd, 1e-15, "pidigits gsl_stats_sd") ; + gsl_test_rel (lag1, expected_lag1, 1e-14, "pidigits autocorrelation") ; + } + + { + double mean = gsl_stats_mean (numacc1, 1, nacc1); + double sd = gsl_stats_sd (numacc1, 1, nacc1); + double lag1 = gsl_stats_lag1_autocorrelation (numacc1, 1, nacc1); + + double expected_mean = 10000002; + double expected_sd = 1; + double expected_lag1 = -0.5; + + gsl_test_rel (mean, expected_mean, 1e-15, "acc1 gsl_stats_mean") ; + gsl_test_rel (sd, expected_sd, 1e-15, "acc1 gsl_stats_sd") ; + gsl_test_rel (lag1, expected_lag1, 1e-15, "acc1 autocorrelation") ; + } + + { + double mean = gsl_stats_mean (numacc2, 1, nacc2); + double sd = gsl_stats_sd (numacc2, 1, nacc2); + double lag1 = gsl_stats_lag1_autocorrelation (numacc2, 1, nacc2); + + double expected_mean = 1.2; + double expected_sd = 0.1; + double expected_lag1 = -0.999; + + gsl_test_rel (mean, expected_mean, 1e-15, "acc2 gsl_stats_mean") ; + gsl_test_rel (sd, expected_sd, 1e-15, "acc2 gsl_stats_sd") ; + gsl_test_rel (lag1, expected_lag1, 1e-10, "acc2 autocorrelation") ; + } + + { + double mean = gsl_stats_mean (numacc3, 1, nacc3); + double sd = gsl_stats_sd (numacc3, 1, nacc3); + double lag1 = gsl_stats_lag1_autocorrelation (numacc3, 1, nacc3); + + double expected_mean = 1000000.2; + double expected_sd = 0.1; + double expected_lag1 = -0.999; + + gsl_test_rel (mean, expected_mean, 1e-15, "acc3 gsl_stats_mean") ; + gsl_test_rel (sd, expected_sd, 1e-9, "acc3 gsl_stats_sd") ; + gsl_test_rel (lag1, expected_lag1, 1e-10, "acc3 autocorrelation") ; + } + + + { + double mean = gsl_stats_mean (numacc4, 1, nacc4); + double sd = gsl_stats_sd (numacc4, 1, nacc4); + double lag1 = gsl_stats_lag1_autocorrelation (numacc4, 1, nacc4); + + double expected_mean = 10000000.2; + double expected_sd = 0.1; + double expected_lag1 = -0.999; + + gsl_test_rel (mean, expected_mean, 1e-15, "acc4 gsl_stats_mean") ; + gsl_test_rel (sd, expected_sd, 1e-7, "acc4 gsl_stats_sd") ; + gsl_test_rel (lag1, expected_lag1, 1e-10, "acc4 autocorrelation") ; + } + + return 0; +} + + + + + + + diff --git a/gsl-1.9/statistics/ttest.c b/gsl-1.9/statistics/ttest.c new file mode 100644 index 0000000..3bc50da --- /dev/null +++ b/gsl-1.9/statistics/ttest.c @@ -0,0 +1,72 @@ +#include <config.h> +#include <math.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "ttest_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "ttest_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "ttest_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "ttest_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "ttest_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "ttest_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "ttest_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "ttest_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "ttest_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "ttest_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "ttest_source.c" +#include "templates_off.h" +#undef BASE_CHAR + + + diff --git a/gsl-1.9/statistics/ttest_source.c b/gsl-1.9/statistics/ttest_source.c new file mode 100644 index 0000000..f1ccc0b --- /dev/null +++ b/gsl-1.9/statistics/ttest_source.c @@ -0,0 +1,42 @@ +/* statistics/ttest_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +double +FUNCTION(gsl_stats,ttest) (const BASE data1[], + const size_t stride1, const size_t n1, + const BASE data2[], + const size_t stride2, const size_t n2) +{ + /* runs a t-test between two datasets representing independent + samples. Tests to see if the difference between means of the + samples is different from zero */ + + /* find means for the two samples */ + const double mean1 = FUNCTION(gsl_stats,mean) (data1, stride1, n1); + const double mean2 = FUNCTION(gsl_stats,mean) (data2, stride2, n2); + + /* find pooled variance for the two samples */ + const double pv = FUNCTION(gsl_stats,pvariance) (data1, stride1, n1, data2, stride2, n2); + + /* calculate the t statistic */ + const double t = (mean1 - mean2) / (sqrt (pv * ((1.0 / n1) + (1.0 / n2)))); + + return t; +} + diff --git a/gsl-1.9/statistics/variance.c b/gsl-1.9/statistics/variance.c new file mode 100644 index 0000000..7c30a0a --- /dev/null +++ b/gsl-1.9/statistics/variance.c @@ -0,0 +1,72 @@ +#include <config.h> +#include <math.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "variance_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "variance_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "variance_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + +#define BASE_ULONG +#include "templates_on.h" +#include "variance_source.c" +#include "templates_off.h" +#undef BASE_ULONG + +#define BASE_LONG +#include "templates_on.h" +#include "variance_source.c" +#include "templates_off.h" +#undef BASE_LONG + +#define BASE_UINT +#include "templates_on.h" +#include "variance_source.c" +#include "templates_off.h" +#undef BASE_UINT + +#define BASE_INT +#include "templates_on.h" +#include "variance_source.c" +#include "templates_off.h" +#undef BASE_INT + +#define BASE_USHORT +#include "templates_on.h" +#include "variance_source.c" +#include "templates_off.h" +#undef BASE_USHORT + +#define BASE_SHORT +#include "templates_on.h" +#include "variance_source.c" +#include "templates_off.h" +#undef BASE_SHORT + +#define BASE_UCHAR +#include "templates_on.h" +#include "variance_source.c" +#include "templates_off.h" +#undef BASE_UCHAR + +#define BASE_CHAR +#include "templates_on.h" +#include "variance_source.c" +#include "templates_off.h" +#undef BASE_CHAR + + + diff --git a/gsl-1.9/statistics/variance_source.c b/gsl-1.9/statistics/variance_source.c new file mode 100644 index 0000000..7578a43 --- /dev/null +++ b/gsl-1.9/statistics/variance_source.c @@ -0,0 +1,90 @@ +/* statistics/variance_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +static double +FUNCTION(compute,variance) (const BASE data[], const size_t stride, const size_t n, const double mean); + +static double +FUNCTION(compute,variance) (const BASE data[], const size_t stride, const size_t n, const double mean) +{ + /* takes a dataset and finds the variance */ + + long double variance = 0 ; + + size_t i; + + /* find the sum of the squares */ + for (i = 0; i < n; i++) + { + const long double delta = (data[i * stride] - mean); + variance += (delta * delta - variance) / (i + 1); + } + + return variance ; +} + + +double +FUNCTION(gsl_stats,variance_with_fixed_mean) (const BASE data[], const size_t stride, const size_t n, const double mean) +{ + const double variance = FUNCTION(compute,variance) (data, stride, n, mean); + return variance; +} + +double +FUNCTION(gsl_stats,sd_with_fixed_mean) (const BASE data[], const size_t stride, const size_t n, const double mean) +{ + const double variance = FUNCTION(compute,variance) (data, stride, n, mean); + const double sd = sqrt (variance); + + return sd; +} + + + +double +FUNCTION(gsl_stats,variance_m) (const BASE data[], const size_t stride, const size_t n, const double mean) +{ + const double variance = FUNCTION(compute,variance) (data, stride, n, mean); + + return variance * ((double)n / (double)(n - 1)); +} + +double +FUNCTION(gsl_stats,sd_m) (const BASE data[], const size_t stride, const size_t n, const double mean) +{ + const double variance = FUNCTION(compute,variance) (data, stride, n, mean); + const double sd = sqrt (variance * ((double)n / (double)(n - 1))); + + return sd; +} + +double +FUNCTION(gsl_stats,variance) (const BASE data[], const size_t stride, const size_t n) +{ + const double mean = FUNCTION(gsl_stats,mean) (data, stride, n); + return FUNCTION(gsl_stats,variance_m)(data, stride, n, mean); +} + +double +FUNCTION(gsl_stats,sd) (const BASE data[], const size_t stride, const size_t n) +{ + const double mean = FUNCTION(gsl_stats,mean) (data, stride, n); + return FUNCTION(gsl_stats,sd_m) (data, stride, n, mean); +} diff --git a/gsl-1.9/statistics/wabsdev.c b/gsl-1.9/statistics/wabsdev.c new file mode 100644 index 0000000..27e0e93 --- /dev/null +++ b/gsl-1.9/statistics/wabsdev.c @@ -0,0 +1,21 @@ +#include <config.h> +#include <math.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "wabsdev_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "wabsdev_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "wabsdev_source.c" +#include "templates_off.h" +#undef BASE_FLOAT diff --git a/gsl-1.9/statistics/wabsdev_source.c b/gsl-1.9/statistics/wabsdev_source.c new file mode 100644 index 0000000..cb86583 --- /dev/null +++ b/gsl-1.9/statistics/wabsdev_source.c @@ -0,0 +1,51 @@ +/* statistics/wabsdev_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +double +FUNCTION(gsl_stats,wabsdev) (const BASE w[], const size_t wstride, const BASE data[], const size_t stride, const size_t n) +{ + const double wmean = FUNCTION(gsl_stats,wmean)(w, wstride, data, stride, n); + return FUNCTION(gsl_stats,wabsdev_m)(w, wstride, data, stride, n, wmean); +} + +double +FUNCTION(gsl_stats,wabsdev_m) (const BASE w[], const size_t wstride, const BASE data[], const size_t stride, const size_t n, const double wmean) +{ + /* Compute the weighted absolute deviation of a dataset */ + + long double wabsdev = 0; + long double W = 0; + + size_t i; + + /* find the sum of the absolute deviations */ + for (i = 0; i < n; i++) + { + BASE wi = w[i * wstride]; + + if (wi > 0) { + const long double delta = fabs(data[i * stride] - wmean); + W += wi ; + wabsdev += (delta - wabsdev) * (wi / W); + } + } + + return wabsdev; +} + diff --git a/gsl-1.9/statistics/wkurtosis.c b/gsl-1.9/statistics/wkurtosis.c new file mode 100644 index 0000000..5b0e0a2 --- /dev/null +++ b/gsl-1.9/statistics/wkurtosis.c @@ -0,0 +1,21 @@ +#include <config.h> +#include <math.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "wkurtosis_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "wkurtosis_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "wkurtosis_source.c" +#include "templates_off.h" +#undef BASE_FLOAT diff --git a/gsl-1.9/statistics/wkurtosis_source.c b/gsl-1.9/statistics/wkurtosis_source.c new file mode 100644 index 0000000..fc1920d --- /dev/null +++ b/gsl-1.9/statistics/wkurtosis_source.c @@ -0,0 +1,62 @@ +/* statistics/wkurtosis_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +double +FUNCTION(gsl_stats,wkurtosis) (const BASE w[], const size_t wstride, const BASE data[], const size_t stride, const size_t n) +{ + const double wmean = FUNCTION(gsl_stats,wmean)(w, wstride, data, stride, n); + const double wsd = FUNCTION(gsl_stats,wsd_m)(w, wstride, data, stride, n, wmean); + return FUNCTION(gsl_stats,wkurtosis_m_sd)(w, wstride, data, stride, n, wmean, wsd); +} + +double +FUNCTION(gsl_stats,wkurtosis_m_sd) (const BASE w[], const size_t wstride, + const BASE data[], + const size_t stride, + const size_t n, + const double wmean, + const double wsd) +{ + /* takes a dataset and finds the kurtosis */ + + long double wavg = 0, kurtosis; + long double W = 0; + size_t i; + + /* find the fourth moment the deviations, normalized by the sd */ + + /* we use a recurrence relation to stably update a running value so + there aren't any large sums that can overflow */ + + for (i = 0; i < n; i++) + { + BASE wi = w[i * wstride]; + + if (wi > 0) { + const long double x = (data[i * stride] - wmean) / wsd; + W += wi ; + wavg += (x * x * x * x - wavg) * (wi / W); + } + } + + kurtosis = wavg - 3.0; /* makes kurtosis zero for a Gaussian */ + + return kurtosis; +} + diff --git a/gsl-1.9/statistics/wmean.c b/gsl-1.9/statistics/wmean.c new file mode 100644 index 0000000..6cb1328 --- /dev/null +++ b/gsl-1.9/statistics/wmean.c @@ -0,0 +1,21 @@ +#include <config.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "wmean_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "wmean_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "wmean_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + diff --git a/gsl-1.9/statistics/wmean_source.c b/gsl-1.9/statistics/wmean_source.c new file mode 100644 index 0000000..edf0507 --- /dev/null +++ b/gsl-1.9/statistics/wmean_source.c @@ -0,0 +1,48 @@ +/* statistics/wmean_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +double +FUNCTION (gsl_stats, wmean) (const BASE w[], const size_t wstride, const BASE data[], const size_t stride, const size_t size) +{ + /* Compute the weighted arithmetic mean M of a dataset using the + recurrence relation + + M(n) = M(n-1) + (data[n] - M(n-1)) (w(n)/(W(n-1) + w(n))) + W(n) = W(n-1) + w(n) + + */ + + long double wmean = 0; + long double W = 0; + + size_t i; + + for (i = 0; i < size; i++) + { + BASE wi = w[i * wstride]; + + if (wi > 0) + { + W += wi; + wmean += (data[i * stride] - wmean) * (wi / W); + } + } + + return wmean; +} diff --git a/gsl-1.9/statistics/wskew.c b/gsl-1.9/statistics/wskew.c new file mode 100644 index 0000000..9e747c6 --- /dev/null +++ b/gsl-1.9/statistics/wskew.c @@ -0,0 +1,22 @@ +#include <config.h> +#include <math.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "wskew_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "wskew_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "wskew_source.c" +#include "templates_off.h" +#undef BASE_FLOAT + diff --git a/gsl-1.9/statistics/wskew_source.c b/gsl-1.9/statistics/wskew_source.c new file mode 100644 index 0000000..5dea05d --- /dev/null +++ b/gsl-1.9/statistics/wskew_source.c @@ -0,0 +1,59 @@ +/* statistics/wskew_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +double +FUNCTION(gsl_stats,wskew) (const BASE w[], const size_t wstride, const BASE data[], const size_t stride, const size_t n) +{ + const double wmean = FUNCTION(gsl_stats,wmean)(w, wstride, data, stride, n); + const double wsd = FUNCTION(gsl_stats,wsd_m)(w, wstride, data, stride, n, wmean); + return FUNCTION(gsl_stats,wskew_m_sd)(w, wstride, data, stride, n, wmean, wsd); +} + +double +FUNCTION(gsl_stats,wskew_m_sd) (const BASE w[], const size_t wstride, + const BASE data[], + const size_t stride, const size_t n, + const double wmean, const double wsd) +{ + /* Compute the weighted skewness of a dataset */ + + long double wskew = 0; + long double W = 0; + + size_t i; + + /* find the sum of the cubed deviations, normalized by the sd. */ + + /* we use a recurrence relation to stably update a running value so + there aren't any large sums that can overflow */ + + for (i = 0; i < n; i++) + { + BASE wi = w[i * wstride]; + + if (wi > 0) { + const long double x = (data[i * stride] - wmean) / wsd; + W += wi ; + wskew += (x * x * x - wskew) * (wi / W); + } + } + + return wskew; +} + diff --git a/gsl-1.9/statistics/wvariance.c b/gsl-1.9/statistics/wvariance.c new file mode 100644 index 0000000..3262664 --- /dev/null +++ b/gsl-1.9/statistics/wvariance.c @@ -0,0 +1,21 @@ +#include <config.h> +#include <math.h> +#include <gsl/gsl_statistics.h> + +#define BASE_LONG_DOUBLE +#include "templates_on.h" +#include "wvariance_source.c" +#include "templates_off.h" +#undef BASE_LONG_DOUBLE + +#define BASE_DOUBLE +#include "templates_on.h" +#include "wvariance_source.c" +#include "templates_off.h" +#undef BASE_DOUBLE + +#define BASE_FLOAT +#include "templates_on.h" +#include "wvariance_source.c" +#include "templates_off.h" +#undef BASE_FLOAT diff --git a/gsl-1.9/statistics/wvariance_source.c b/gsl-1.9/statistics/wvariance_source.c new file mode 100644 index 0000000..d815b1e --- /dev/null +++ b/gsl-1.9/statistics/wvariance_source.c @@ -0,0 +1,127 @@ +/* statistics/wvariance_source.c + * + * Copyright (C) 1996, 1997, 1998, 1999, 2000 Jim Davies, Brian Gough + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +static double +FUNCTION(compute,wvariance) (const BASE w[], const size_t wstride, const BASE data[], const size_t stride, const size_t n, const double wmean); + +static double +FUNCTION(compute,factor) (const BASE w[], const size_t wstride, const size_t n); + +static double +FUNCTION(compute,wvariance) (const BASE w[], const size_t wstride, const BASE data[], const size_t stride, const size_t n, const double wmean) +{ + /* takes a dataset and finds the weighted variance */ + + long double wvariance = 0 ; + long double W = 0; + + size_t i; + + /* find the sum of the squares */ + for (i = 0; i < n; i++) + { + BASE wi = w[i * wstride]; + + if (wi > 0) { + const long double delta = (data[i * stride] - wmean); + W += wi ; + wvariance += (delta * delta - wvariance) * (wi / W); + } + } + + return wvariance ; +} + +static double +FUNCTION(compute,factor) (const BASE w[], const size_t wstride, const size_t n) +{ + /* Find the factor ``N/(N-1)'' which multiplies the raw std dev */ + + long double a = 0 ; + long double b = 0; + long double factor; + + size_t i; + + /* find the sum of the squares */ + for (i = 0; i < n; i++) + { + BASE wi = w[i * wstride]; + + if (wi > 0) + { + a += wi ; + b += wi * wi ; + } + } + + factor = (a*a) / ((a*a) - b); + + return factor ; +} + +double +FUNCTION(gsl_stats,wvariance_with_fixed_mean) (const BASE w[], const size_t wstride, const BASE data[], const size_t stride, const size_t n, const double wmean) +{ + const double wvariance = FUNCTION(compute,wvariance) (w, wstride, data, stride, n, wmean); + return wvariance; +} + +double +FUNCTION(gsl_stats,wsd_with_fixed_mean) (const BASE w[], const size_t wstride, const BASE data[], const size_t stride, const size_t n, const double wmean) +{ + const double wvariance = FUNCTION(compute,wvariance) (w, wstride, data, stride, n, wmean); + const double wsd = sqrt (wvariance); + + return wsd; +} + + +double +FUNCTION(gsl_stats,wvariance_m) (const BASE w[], const size_t wstride, const BASE data[], const size_t stride, const size_t n, const double wmean) +{ + const double variance = FUNCTION(compute,wvariance) (w, wstride, data, stride, n, wmean); + const double scale = FUNCTION(compute,factor)(w, wstride, n); + + return scale * variance; +} + +double +FUNCTION(gsl_stats,wsd_m) (const BASE w[], const size_t wstride, const BASE data[], const size_t stride, const size_t n, const double wmean) +{ + const double variance = FUNCTION(compute,wvariance) (w, wstride, data, stride, n, wmean); + const double scale = FUNCTION(compute,factor)(w, wstride, n); + const double wsd = sqrt(scale * variance) ; + + return wsd; +} + +double +FUNCTION(gsl_stats,wsd) (const BASE w[], const size_t wstride, const BASE data[], const size_t stride, const size_t n) +{ + const double wmean = FUNCTION(gsl_stats,wmean) (w, wstride, data, stride, n); + return FUNCTION(gsl_stats,wsd_m) (w, wstride, data, stride, n, wmean) ; +} + +double +FUNCTION(gsl_stats,wvariance) (const BASE w[], const size_t wstride, const BASE data[], const size_t stride, const size_t n) +{ + const double wmean = FUNCTION(gsl_stats,wmean) (w, wstride, data, stride, n); + return FUNCTION(gsl_stats,wvariance_m)(w, wstride, data, stride, n, wmean); +} |