#! /bin/bash -ue
# Last edited on 2025-05-04 22:49:06 by stolfi

binplots=( \
  voyn/prs:bgly:9.0:-1.00 \
  voyn/lab:bgly:9.0:-1.00 \
  voyn/maj:bgly:9.0:-1.00 \
  engl/twp:lets:9.0:-0.75 \
  \
  voyn/prs:qoko:6.0:-1.80 \
  viet/ptt:viqr:6.0:-1.55 \
  tibe/ccv:acip:4.5:-1.90 \
  viet/ptt:phon:0.9:-2.40 \
  chin/ptt:phon:1.5:-3.00 \
  chin/ptt:stpy:4.0:-1.90 \
  chin/ptt:fxpy:4.0:-1.90 \
  voyp/grs:bgly:9.0:-1.00 \
  voyp/grm:bgly:9.0:-0.50 \
  \
  engl/wow:lets:18.0:+2.25 \
  latn/ptt:lets:20.0:+2.50 \
  grek/nwt:lets:21.0:+3.25 \
  span/qvi:lets:18.0:+1.75 \
  geez/gok:sera:18.0:+1.50 \
  hebr/tad:jshb:12.0:-0.00 \
  arab/quv:jsar:18.0:+0.75 \
  arab/qcs:jsar:10.0:-0.50 \
  enrc/wow:lets:18.0:+1.50 \
  arab/qud:jsar:9.0:-0.75 \
)

nonbinlots=( \
)

for plt in  ${binplots[@]} ; do
  p=( `echo ${plt} | tr ':' ' '` )
  sample="${p[0]}"; elem="${p[1]}"; ntot="${p[2]}"; nshf="${p[3]}";
  ymax=`gawk -v ntot=${ntot} 'BEGIN{printf "%.2f",1.0/sqrt(ntot);}'`
  for tw in t w ; do
    smptag=`echo ${sample}/tot.1 | tr '/' '-'`
    oname="${smptag}-binom-${tw}-${elem}-lengths"
    if [[ "/${tw}" == "/w" ]]; then
      btot="${ntot}"; bshf="${nshf}";
    else
      btot="0"; bshf="0";
    fi
    echo "=== fig/${oname} ==="
    compare_elem_count_distribs.sh \
        -freqs -ymax ${ymax} -xmax 15 \
        -binom "${btot}" "${bshf}" \
        dat/${sample}/tot.1/gud-fact-${elem}-${tw}.lhi  "${sample} (${elem})" 1.00 1 1 \
      fig/${oname}
    update_paper_include.sh fig/${oname}.eps tex/${oname}.eps
    update_paper_include.sh fig/${oname}.png tex/${oname}.png
  done
done 
