MCPcopy Index your code
hub / github.com/TeaCoder52/patcode / estimateEntropy

Function estimateEntropy

src/analyze.ts:30–42  ·  view source on GitHub ↗
(code: string)

Source from the content-addressed store, hash-verified

28}
29
30function estimateEntropy(code: string): number {
31 const freq: Record<string, number> = {}
32
33 for (const d of code) freq[d] = (freq[d] || 0) + 1
34
35 let entropy = 0
36 for (const k in freq) {
37 const p = freq[k] / code.length
38 entropy -= p * Math.log2(p)
39 }
40
41 return entropy * code.length
42}
43
44function collisionRisk(
45 code: string,

Callers 1

analyzeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected