(UP)

This script takes a file with numbers in the format of one column. Output is file 'res-*' which gives a STATISTICAL DISTRIBUTION of the numbers from the original file with size of 'bin' delta = 1% (division by 100 ) of the bandwidth of values (i.e. difference between the highest and the lowest value in the set of numbers in the original file).
(script, sample-in, sample-out)

if [ $# -ne 1 ]
then
echo
echo Usage: $0 [filename]
echo output file is res-filename
echo
exit
fi

sed 's/\.......//g' $1 > s-$1
sort -i -n s-$1 > st-$1
rm s-$1

first=`head -1 st-$1`
last=`tail -1 st-$1`
delta=`expr $last / 100 - $first / 100`
numofitems=`more st-$1 | wc -l`
halfn=`expr $numofitems / 2`
echo $numofitems $halfn
probab=0
scan=$first
echo > res-$1
num=1

while [ $num -lt $halfn ]
do
number=`head -$num st-$1 | tail -1`
if [ $number -le $scan ]
then
probab=`expr $probab + 1`
else
echo $scan $probab >> res-$1
probab=0
scan=`expr $scan + $delta`
fi
num=`expr $num + 1`
done

while [ $num -gt 0 ]
do
number=`tail -$num st-$1 | head -1`
if [ $number -le $scan ]
then
probab=`expr $probab + 1`
else
echo $scan $probab >> res-$1
probab=0
scan=`expr $scan + $delta`
fi
num=`expr $num - 1`
done

rm st-$1


(c) January 2001 Viktor Yarmolenko (e-mail:viktor.yarmolenko@physics.org)

(UP)








  Science
Programming
Other Activities






©2002-2004 Viktor Yarmolenko