Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,22 @@
const std = @import("std");
const math = std.math;
pub fn main() !void {
const stdout = std.io.getStdOut().outStream();
try stdout.print("{d:.12}\n", .{H("1223334444")});
}
fn H(s: []const u8) f64 {
var counts = [_]u16{0} ** 256;
for (s) |ch|
counts[ch] += 1;
var h: f64 = 0;
for (counts) |c|
if (c != 0) {
const p = @intToFloat(f64, c) / @intToFloat(f64, s.len);
h -= p * math.log2(p);
};
return h;
}