function alfabetAnalyse($codtxt, $alfa)
{
    global $AP, $ks_hilf;
    $alfahier = @hauf($codtxt);
    for ($t = 0; $t < sizeof($alfahier); $t++) {
        $p[] = 100 * prob($alfahier[$t], strlen($codtxt));
    }
    $alfahier = $p;
    $VX = varianz($AP[de]);
    $SX = sqrt(varianz($AP[de]));
    $VY = varianz($alfahier);
    $SY = sqrt(varianz($alfahier));
    $cov = covarianz($AP[de], $alfahier);
    $r = @abs($cov / sqrt($VX * $VY));
    for ($t = 0; $t < sizeof($alfa); $t++) {
        $ba1 .= "<img src={$ks_hilf['pfad']}/image/letter" . $t . ".gif border=0><img src={$ks_hilf['pfad']}/image/bar0.jpg width=3 border=0>";
        $ba2 .= "<img src={$ks_hilf['pfad']}/image/letter" . ($t + $rotv) % sizeof($alfa) . ".gif border=0><img src={$ks_hilf['pfad']}/image/bar0.jpg width=3 border=0>";
    }
    $lang_normalalphabet = JTEXT::_('NORMALALPHABET');
    $lang_STATISTICALDATA = JTEXT::_('STATISTICALDATA');
    $lang_VARIANCE = JTEXT::_('VARIANCE');
    $lang_DEFAULTABWEICHUNG = JTEXT::_('DEFAULTABWEICHUNG');
    $lang_CURRENTALPHABET = JTEXT::_('CURRENTALPHABET');
    $lang_SIGNS = JTEXT::_('SIGNS');
    $lang_ENTROPY = JTEXT::_('ENTROPY');
    $out .= '<table border=0><tr><td>
            <b>' . $lang_normalalphabet . '</b><br>' . $lang_STATISTICALDATA . ':<br>' . '<br>' . $lang_VARIANCE . ': ' . round($VX, 5) . '<br>' . $lang_DEFAULTABWEICHUNG . ':  ' . round($SX, 5) . '</td><td valign=middle>' . showakt($AP[de], 50, 1, 5, 3, 0) . '<center><div class=text7 >' . $ba1 . '</div></center>' . '</td></tr>' . '<tr><td>' . '<br><b>' . $lang_CURRENTALPHABET . '</b><br>' . $lang_STATISTICALDATA . ':<br>' . '<br>' . $lang_VARIANCE . ':    ' . round($VY, 5) . '<br>' . $lang_DEFAULTABWEICHUNG . ':     ' . round($SY, 5) . '<br>' . '</td><td valign=middle><br>' . showakt($alfahier, 50, 1, 5, 3, 0) . '<center><div class=text7 >' . $ba2 . '</div></center>' . '</td></tr><tr><td>' . '<br>' . $lang_SIGNS . ':    ' . strlen($codtxt) . '<br>' . $lang_ENTROPY . ':   ' . round(entropie($codtxt), 5) . '</td></tr></table>';
    return $out;
}
function alfabetAnalyse($codtxt, $alfa)
{
    global $AP, $ks_hilf;
    $alfahier = @hauf($codtxt);
    for ($t = 0; $t < sizeof($alfahier); $t++) {
        $p[] = 100 * prob($alfahier[$t], strlen($codtxt));
    }
    $alfahier = $p;
    $VX = varianz($AP[de]);
    $SX = sqrt(varianz($AP[de]));
    $VY = varianz($alfahier);
    $SY = sqrt(varianz($alfahier));
    $cov = covarianz($AP[de], $alfahier);
    $r = @abs($cov / sqrt($VX * $VY));
    for ($t = 0; $t < sizeof($alfa); $t++) {
        $ba1 .= "<img src={$ks_hilf['pfad']}/image/letter" . $t . ".gif border=0><img src={$ks_hilf['pfad']}/image/bar0.jpg width=3 border=0>";
        $ba2 .= "<img src={$ks_hilf['pfad']}/image/letter" . ($t + $rotv) % sizeof($alfa) . ".gif border=0><img src={$ks_hilf['pfad']}/image/bar0.jpg width=3 border=0>";
    }
    $out .= '<table border=0><tr><td>
            <b>Normales Alfabet</b><br>Statistische Daten:<br>' . '<br>Varianz: ' . round($VX, 5) . '<br>StdAbw:  ' . round($SX, 5) . '</td><td valign=middle>' . showakt($AP[de], 50, 1, 5, 3, 0) . '<center><div class=text7 >' . $ba1 . '</div></center>' . '</td></tr>' . '<tr><td>' . '<br><b>vorliegendes Alfabet</b><br>Statistische Daten:<br>' . '<br>Varianz:    ' . round($VY, 5) . '<br>StdAbw:     ' . round($SY, 5) . '<br>' . '</td><td valign=middle><br>' . showakt($alfahier, 50, 1, 5, 3, 0) . '<center><div class=text7 >' . $ba2 . '</div></center>' . '</td></tr><tr><td>' . '<br>Zeichen:    ' . strlen($codtxt) . '<br>Entropie:   ' . round(entropie($codtxt), 5) . '<br>KI-Index:   ' . round(koinzidenzIndex($codtxt), 5) . '</td><td>' . '<br>GV-Maß1:    ' . round(gvmass($codtxt, $alfahier), 5) . '<br>GV-Maß2:    ' . round(gvmass2($codtxt, $alfahier), 5) . '</td></tr></table><div class=text10><br>Kovarianz:  ' . round($cov, 5) . '<br>KorrKoeff:  ' . round($r, 5) . '</div>';
    return $out;
}
function findmul($text)
{
    # Alfabetmultiplikator finden
    global $AP;
    global $alfa;
    $mulzahl = teilerfremde(sizeof($alfa));
    $VX = varianz($AP[de]);
    $SX = sqrt(varianz($AP[de]));
    $sp = hauf($text);
    $sps = array_sum($sp);
    for ($t = 0; $t < sizeof($sp); $t++) {
        $sp[$t] = @round($sp[$t] / $sps * 100, 2);
    }
    for ($t = 0; $t < sizeof($mulzahl); $t++) {
        for ($u = 0; $u < sizeof($sp); $u++) {
            $sp2[$u] = $sp[$mulzahl[$t] * $u % sizeof($sp)];
        }
        $VY = varianz($sp2);
        $SY = sqrt(varianz($sp2));
        $cov = covarianz($AP[de], $sp2);
        $r[$t] = @abs($cov / sqrt($VX * $VY));
    }
    $b = array_search(max($r), $r);
    return $mulzahl[$b];
}