Data update

This commit is contained in:
Ingy döt Net 2025-08-11 18:05:26 -07:00
parent 4d5544505c
commit 4924dd0264
3073 changed files with 55820 additions and 4408 deletions

View file

@ -0,0 +1,16 @@
# h should be a DuckDB histogram and n should be map_values(h).list_sum()
create or replace function h2e(h, n) as (
- map_values(h).list_transform( x -> x * log2(x/n)).list_sum() / n
);
# str is normally a string but if not, will be cast to one
create or replace function shannon_entropy(str) as (
with cte as (
from unnest( string_split(str::VARCHAR,'')) _(s)
),
n as (select count(*) as n from cte),
h as (select histogram(s) as h from cte)
select h2e(h,n) from h, n
);
select shannon_entropy(1223334444);