Commit 37f80ad2 authored by Pietro Battiston's avatar Pietro Battiston

Merge tag 'upstream/5.6.6'

Upstream version 5.6.6
parents e11b1a82 79cf4042
2015-06-12 Giulio Bottazzi <bottazzi@sssup.it>
* ALL: Tagged with CVS using
#cvs tag gbutils-5-6-6
* configure.ac: Source package version updated to 5.6.6.
* gbstat.c: added the computation of the mode using the Half
Sample Method by Robertson and Cryer.
2015-06-06 Giulio Bottazzi <bottazzi@sssup.it>
* ALL: Tagged with CVS using
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for gbutils 5.6.5.
# Generated by GNU Autoconf 2.69 for gbutils 5.6.6.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
......@@ -577,8 +577,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='gbutils'
PACKAGE_TARNAME='gbutils'
PACKAGE_VERSION='5.6.5'
PACKAGE_STRING='gbutils 5.6.5'
PACKAGE_VERSION='5.6.6'
PACKAGE_STRING='gbutils 5.6.6'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
......@@ -1319,7 +1319,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures gbutils 5.6.5 to adapt to many kinds of systems.
\`configure' configures gbutils 5.6.6 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1389,7 +1389,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of gbutils 5.6.5:";;
short | recursive ) echo "Configuration of gbutils 5.6.6:";;
esac
cat <<\_ACEOF
......@@ -1480,7 +1480,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
gbutils configure 5.6.5
gbutils configure 5.6.6
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -1945,7 +1945,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by gbutils $as_me 5.6.5, which was
It was created by gbutils $as_me 5.6.6, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
......@@ -2809,7 +2809,7 @@ fi
# Define the identity of the package.
PACKAGE='gbutils'
VERSION='5.6.5'
VERSION='5.6.6'
cat >>confdefs.h <<_ACEOF
......@@ -6220,7 +6220,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by gbutils $as_me 5.6.5, which was
This file was extended by gbutils $as_me 5.6.6, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -6286,7 +6286,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
gbutils config.status 5.6.5
gbutils config.status 5.6.6
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
......
# Process this file with autoconf to produce a configure script.
AC_INIT([gbutils],[5.6.5])
AC_INIT([gbutils],[5.6.6])
AC_CONFIG_SRCDIR([tools.c])
AM_INIT_AUTOMAKE
......
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.44.1.
.TH GBENV "1" "June 2015" "gbenv 5.6.5" "User Commands"
.TH GBENV "1" "June 2015" "gbenv 5.6.6" "User Commands"
.SH NAME
gbenv \- Floating point locale, and gbutils settings
.SH DESCRIPTION
......
......@@ -11,6 +11,7 @@ average deviation, minimum, maximum, median (if option \fB\-m\fR is specified)
and number of valid observations. Option \fB\-O\fR allows one to select specific
statistics. With option \fB\-t\fR statistics are printed for each column of data
separately. A header line is added with the meaning of the different columns.
The mode is computed using the Half\-Sample method.
.SH OPTIONS
.TP
\fB\-m\fR
......@@ -23,7 +24,7 @@ print statistics for each column of input
short: mean std skew kurt adev min max (median) num
.TP
\fB\-O\fR
select output: mean,std,skew,kurt,adev,min,max,median,num
select output: mean,std,skew,kurt,adev,min,max,median,num,mode
.TP
\fB\-F\fR
specify the input fields separators (default " \et")
......@@ -37,7 +38,7 @@ of all the data in 'file'
.TP
gbstat \-ts < file
compute statistics for each columns separately.
Since option \-s is active, the header is omitted.
Since option \-s is provided, the header is omitted.
.SH AUTHOR
Written by Giulio Bottazzi
.SH "REPORTING BUGS"
......
......@@ -18,19 +18,67 @@
#include "tools.h"
double HSM(double *vals,size_t size){
double mode;
size_t n=size;
size_t i=0;
while(n>3){
size_t h;
size_t j=i;
size_t N=(size_t) ceil(n/2.0);
double w=vals[i+n-1]-vals[i];
/* printf("from %d to %d\n",i,i+n-N); */
for(h=i; h < i+n-N+1; h++){
double dtmp1=vals[h+N-1]-vals[h];
/* printf("w[%d]=%f ",h,dtmp1); */
if(dtmp1<w){
w=dtmp1;
j=h;
}
}
n=N;
i=j;
/* printf("\n[%+f,%+f] [%d,%d] %d\n",vals[i],vals[i+n-1],i,i+n-1,n); */
}
if(n==3){
if(vals[i+2]-vals[i+1] < vals[i+1]-vals[i])
mode = 0.5*(vals[i+2]+vals[i+1]);
else if (vals[i+2]-vals[i+1] == vals[i+1]-vals[i])
mode = vals[i+1];
else
mode=0.5*(vals[i+1]+vals[i]);
}
else if(n==2){
mode=0.5*(vals[i]+vals[i+1]);
}
else if (n==1){
mode=vals[i];
}
return mode;
}
int main(int argc,char* argv[]){
/* output variables */
char o_median=0;
double result[9];
char o_mode=0;
double result[10];
double variance;
char *splitstring = strdup(" \t");
/* options options */
char * const output_opts[] = {"mean","std","skew","kurt","adev","min","max","num","median",NULL};
char * const output_description[] = {"mean","stdev","skewness","kurtosis","average dev.","min","max","valid","median",NULL};
char * const output_opts[] = {"mean","std","skew","kurt","adev","min","max","num","median","mode",NULL};
char * const output_description[] = {"mean","stdev","skewness","kurtosis","average dev.","min","max","valid","median","mode",NULL};
size_t outnum;
size_t *outtype;
......@@ -74,19 +122,20 @@ int main(int argc,char* argv[]){
fprintf(stdout,"and number of valid observations. Option -O allows one to select specific\n");
fprintf(stdout,"statistics. With option -t statistics are printed for each column of data\n");
fprintf(stdout,"separately. A header line is added with the meaning of the different columns.\n");
fprintf(stdout,"The mode is computed using the Half-Sample method.\n");
fprintf(stdout,"\nUsage: %s [options]\n\n",argv[0]);
fprintf(stdout,"Options: \n");
fprintf(stdout," -m add the sample median to the estimated statistics \n");
fprintf(stdout," -t print statistics for each column of input \n");
fprintf(stdout," -s short: mean std skew kurt adev min max (median) num \n");
fprintf(stdout," -O select output: mean,std,skew,kurt,adev,min,max,median,num \n");
fprintf(stdout," -F specify the input fields separators (default \" \\t\") \n");
fprintf(stdout,"Options: \n");
fprintf(stdout," -m add the sample median to the estimated statistics \n");
fprintf(stdout," -t print statistics for each column of input \n");
fprintf(stdout," -s short: mean std skew kurt adev min max (median) num \n");
fprintf(stdout," -O select output: mean,std,skew,kurt,adev,min,max,median,num,mode \n");
fprintf(stdout," -F specify the input fields separators (default \" \\t\") \n");
fprintf(stdout," -h this help\n");
fprintf(stdout,"Examples:\n");
fprintf(stdout," gbstat -O median,kurt < file compute the median and the kurtosis\n");
fprintf(stdout," of all the data in 'file'\n");
fprintf(stdout," gbstat -ts < file compute statistics for each columns separately.\n");
fprintf(stdout," Since option -s is active, the header is omitted.\n");
fprintf(stdout," Since option -s is provided, the header is omitted.\n");
finalize_program();return(0);
}
else if(opt=='m'){
......@@ -138,6 +187,17 @@ int main(int argc,char* argv[]){
/* initialize global variables */
initialize_program(argv[0]);
/* check if median or the mode should be computed */
{
size_t i;
for(i=0;i<outnum;i++)
if(outtype[i]==8)
o_median=1;
else if (outtype[i]==9)
o_mode=1;
}
if(!o_table){
size_t size,i;
double *vals=NULL;
......@@ -150,17 +210,17 @@ int main(int argc,char* argv[]){
moment(vals,size,
&(result[0]),&(result[4]),&(result[1]),&variance,&(result[2]),&(result[3]),&(result[5]),&(result[6]));
/* check if median should be computed */
for(i=0;i<outnum;i++)
if(outtype[i]==8)
o_median=1;
/* sort the data */
if(o_median || o_mode)
qsort(vals,size,sizeof(double),sort_by_value);
/* compute the median */
if(o_median){
/* sort the data */
qsort(vals,size,sizeof(double),sort_by_value);
if(o_median)
result[8] = (size%2 ==0 ? .5*(vals[size/2-1]+vals[size/2]) : vals[(size-1)/2]);
}
/* compute the mode */
if(o_mode)
result[9]=HSM(vals,size);
if(o_short){
for(i=0;i<outnum-1;i++)
......@@ -183,11 +243,6 @@ int main(int argc,char* argv[]){
/*double *set;*/
loadtable(&vals,&rows,&columns,0,splitstring);
/* check if median should be computed */
for(i=0;i<outnum;i++)
if(outtype[i]==8)
o_median=1;
if(!o_short){
printf("#");
......@@ -206,11 +261,17 @@ int main(int argc,char* argv[]){
moment(vals[i],itmp1,
&(result[0]),&(result[4]),&(result[1]),&variance,&(result[2]),&(result[3]),&(result[5]),&(result[6]));
if(o_median){
/* sort the data */
/* sort the data */
if(o_median || o_mode)
qsort(vals[i],itmp1,sizeof(double),sort_by_value);
/* compute the median */
if(o_median)
result[8] = (itmp1%2 == 0 ? .5*(vals[i][itmp1/2-1]+vals[i][itmp1/2]) : vals[i][(itmp1-1)/2]);
}
/* compute the mode */
if(o_mode)
result[9]=HSM(vals[i],itmp1);
for(j=0;j<outnum-1;j++)
printf(FLOAT_SEP,result[outtype[j]]);
......
......@@ -90,8 +90,8 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = lib
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am getdelim.h \
strchrnul.c getline.h getdelim.c getline.c getsubopt.c
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am getline.c \
getdelim.c strchrnul.c getdelim.h getsubopt.c getline.h
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/getdelim.m4 \
$(top_srcdir)/m4/getline.m4 $(top_srcdir)/m4/getsubopt.m4 \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment