2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2026-04-04 04:18:22 +00:00
This commit is contained in:
2023-04-04 18:38:28 +03:00
parent 5966598c9f
commit 0ceaee88aa
6 changed files with 76 additions and 6 deletions

View File

@@ -14,6 +14,11 @@ namespace Esiur.Analysis.Coding
return frequencies.Sum(x => ((double)x / total * -Log2(x)));
}
public static double AverageLength<T>(this CodeWord<T>[] words)
{
return words.Sum(x => x.Length) / (double)words.Length;
}
public static double Log2(double value) => Math.Log10(value) / Math.Log10(2);
}
}