110825__/tex/sh110825wahrscheinlichkeit.sh

#!/bin/bash

# (c) david vajda
# bessere wahrscheinlichkeit
# 11/08/25

echo "# (c) david vajda"
echo "# bessere wahrscheinlichkeit"
echo "# 11/08/25"

m=4
t1=("e3 e2 e1 e0")
S1=("t  f  f  f " "f  t  f  f " "f  f  t  f " "f  f  f  t ")
S2=(8 4 2 1)
S3=(4 3 2 1)

echo -n "nr. "
i=0
while [ $i -lt $m ]
do
    echo -n "${t1[$i]}"
    i=$(($i+1))
done
echo ""
k=32
i=0
while [ $i -lt $k ]
do
    printf "%02d. " $i
    echo "${S1[$(($RANDOM%4))]}"
    i=$(($i+1))
done

ES=()
i=0
while [ $i -lt 16 ]
do
    s="{"
    if [ $(($i%2)) -eq 0 ]
    then
        s="$s e1 "
    fi
    if [ $((($i/2)%2)) -eq 0 ]
    then
        s="$s e2 "
    fi
    if [ $((($i/4)%2)) -eq 0 ]
    then
        s="$s e3 "
    fi
    if [ $((($i/8)%2)) -eq 0 ]
    then
        s="$s e4 "
    fi

    s="$s}"
    # echo "$s"
    ES+=("$s")
    i=$(($i+1))
done

i=0
j=41
while [ $i -lt 16 ]
do
    if [ $(($RANDOM%2)) == 0 ]
    then
        echo -n "$j" | xxd -p -r
        echo "=${ES[$i]}"
        j=$(($j+1))
    fi
    i=$(($i+1))
done