Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,28 +0,0 @@
with Ada.Text_IO, Ada.Float_Text_IO, Ada.Numerics.Elementary_Functions;
procedure Count_Entropy is
package TIO renames Ada.Text_IO;
Count: array(Character) of Natural := (others => 0);
Sum: Natural := 0;
Line: String := "1223334444";
begin
for I in Line'Range loop -- count the characters
Count(Line(I)) := Count(Line(I))+1;
Sum := Sum + 1;
end loop;
declare -- compute the entropy and print it
function P(C: Character) return Float is (Float(Count(C)) / Float(Sum));
use Ada.Numerics.Elementary_Functions, Ada.Float_Text_IO;
Result: Float := 0.0;
begin
for Ch in Character loop
Result := Result -
(if P(Ch)=0.0 then 0.0 else P(Ch) * Log(P(Ch), Base => 2.0));
end loop;
Put(Result, Fore => 1, Aft => 5, Exp => 0);
end;
end Count_Entropy;

View file

@ -4,7 +4,7 @@ entropy: function [s][
unless key? t c -> t\[c]: 0
t\[c]: t\[c] + 1
]
result: new 0
result: 0
loop values t 'x ->
'result - (x//(size s)) * log x//(size s) 2

View file

@ -1,40 +0,0 @@
(defun entropy (str / log2 eCalc strList len ent cnt n new end cPrev)
(defun log2 (x)
(if (> x 0)
(/ (log x) (log 2.0))
)
)
(defun eCalc (cnt len / p)
(setq p (/ (float cnt) len))
(* p (log2 p))
)
(setq
strList (acad_strlsort (mapcar 'chr (vl-string->list str)))
len (length strList)
ent 0.0
cnt 0
n 0
)
(foreach c strList
(setq
n (1+ n)
new (and cPrev (not (eq c cPrev)))
end (= n len)
)
(if (or new end)
(setq
cnt (if (and end (not new)) (1+ cnt) cnt)
ent (+ ent (eCalc cnt len))
cnt 0
)
)
(if (and new end)
(setq ent (+ ent (eCalc 1 len)))
)
(setq
cnt (1+ cnt)
cPrev c
)
)
(* -1 ent)
)

View file

@ -3,11 +3,9 @@ func entropy s$ .
for c$ in strchars s$
d[strcode c$] += 1
.
for cnt in d[]
if cnt > 0
prop = cnt / len s$
entr -= (prop * log10 prop / log10 2)
.
for cnt in d[] : if cnt > 0
prop = cnt / len s$
entr -= prop * log prop 2
.
return entr
.

View file

@ -9,7 +9,7 @@ extension op
= self.ln() / 2.ln();
}
public program()
public Program()
{
var input := console.readLine();
var infoC := 0.0r;

View file

@ -1,15 +0,0 @@
(defun shannon-entropy (input)
(let ((freq-table (make-hash-table))
(entropy 0)
(length (+ (length input) 0.0)))
(mapcar (lambda (x)
(puthash x
(+ 1 (gethash x freq-table 0))
freq-table))
input)
(maphash (lambda (k v)
(set 'entropy (+ entropy
(* (/ v length)
(log (/ v length) 2)))))
freq-table)
(- entropy)))

View file

@ -1,2 +0,0 @@
(shannon-entropy "1223334444")
1.8464393446710154

View file

@ -1,9 +0,0 @@
function entropy ($string) {
$n = $string.Length
$string.ToCharArray() | group | foreach{
$p = $_.Count/$n
$i = [Math]::Log($p,2)
-$p*$i
} | measure -Sum | foreach Sum
}
entropy "1223334444"