Add a function to convert a count map to a reversed map.

This commit is contained in:
2023-11-12 21:50:02 +02:00
parent 2cc5be57c8
commit c03dc68458
2 changed files with 17 additions and 0 deletions
@@ -11,6 +11,16 @@
(inc (get acc val 0))))
{} text))
(defn reverse-count-characters
"Convert a map of pairs to a map where the characters grouped by the count and a count is the key."
[count-map]
(reduce
(fn [acc [symbol count]]
(->> (conj (get acc count []) symbol)
(into [])
(assoc acc count)))
{} count-map))
(defn chi-squared-letter-statistic
"To calculate the frequency distribution of a letter."
[letter-count letter-frequence length-text]