Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
10
Task/Entropy/Jq/entropy-1.jq
Normal file
10
Task/Entropy/Jq/entropy-1.jq
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# Input: an array of strings.
|
||||
# Output: an object with the strings as keys, the values of which are the corresponding frequencies.
|
||||
def counter:
|
||||
reduce .[] as $item ( {}; .[$item] += 1 ) ;
|
||||
|
||||
# entropy in bits of the input string
|
||||
def entropy:
|
||||
(explode | map( [.] | implode ) | counter
|
||||
| [ .[] | . * log ] | add) as $sum
|
||||
| ((length|log) - ($sum / length)) / (2|log) ;
|
||||
1
Task/Entropy/Jq/entropy-2.jq
Normal file
1
Task/Entropy/Jq/entropy-2.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
"1223334444" | entropy # => 1.8464393446710154
|
||||
Loading…
Add table
Add a link
Reference in a new issue