> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/e/entropy/narcissist.md).

# Narcissist

```ruby
func entropy(s) {
    [0,
        s.chars.freq.values.map {|c|
            var f = c/s.len
            f * f.log2
        }...
    ]«-»
}
 
say entropy(File(__FILE__).open_r.slurp)
```

#### Output:

```
4.27307750866434915713432109186549
```
