2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2026-04-04 04:18:22 +00:00

Huffman base2/3

This commit is contained in:
2023-03-27 15:12:40 +03:00
parent 60738d01b4
commit 9a74a01bdf
8 changed files with 268 additions and 96 deletions

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Esiur.Analysis.Coding
{
public static class Functions
{
public static double Entropy(int[] frequencies)
{
double total = frequencies.Sum();
return frequencies.Sum(x => ((double)x / total * -Log2(x)));
}
public static double Log2(double value) => Math.Log10(value) / Math.Log10(2);
}
}