Commit 51a2eb55 authored by Thomas Huetter's avatar Thomas Huetter

statistics: added a script that outputs the min, max and average tree sizes of a given input file

parent 3113fb85
#!/bin/bash
# file: nodes_per_tree.sh
#
# usage: ./prepare_data.sh <inputfile>
#
# Program: Counts the number of nodes per line. Ouputs the maximal,
# minimal and average number of nodes per line of the given
# inputfile containing a tree in bracket notation per line.
#
# Author: Thomas Huetter
if [ -z "$1" ]
then
echo "Argument missing."
echo "Usage: ./prepare_data.sh <inputfile>"
exit 1
fi
awk -F '\{' '{print NF-1}' $1 | awk 'NR == 1 { max=$1; min=$1; sum=0 }
{ if ($1>max) max=$1; if ($1<min) min=$1; sum+=$1;}
END {printf "Min: %d\tMax: %d\tAverage: %f\n", min, max, sum/NR}'
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