<commit_before>algorithms
==========

Common useful algorithms implemented in Go. Currently includes only a streaming median implementation.

Streaming Median
----------------

Streaming Median computes the running median of a list of values as they are added. This is useful when large datasets or different threads (goroutines) are involved, and sorting would be too costly. The algorithm is implemented internally using two heaps. It adds a number and computes the new median in O(logN), and can compute the median of the full list in O(NlogN), where N is the length of the list.

```
import (
    "fmt"
    "github.com/hermanschaaf/median"
)

func main(){
   lst := []int{1,2,3,4,5}
   sm := median.StreamingMedian{}
   for i := range lst {
       m := sm.Add(lst[i])
       fmt.Printf("Added %v, new median is %v\n", lst[i], m)
   }
}
```<commit_msg>Add output to readme in median example<commit_after>algorithms
==========

Common useful algorithms implemented in Go. Currently includes only a streaming median implementation.

Streaming Median
----------------

Streaming Median computes the running median of a list of values as they are added. This is useful when large datasets or different threads (goroutines) are involved, and sorting would be too costly. The algorithm is implemented internally using two heaps. It adds a number and computes the new median in O(logN), and can compute the median of the full list in O(NlogN), where N is the length of the list.

```
import (
    "fmt"
    "github.com/hermanschaaf/algorithms/median"
)

func main(){
   lst := []int{1,2,3,4,5}
   sm := median.StreamingMedian{}
   for i := range lst {
       m := sm.Add(lst[i])
       fmt.Printf("Added %v, new median is %v\n", lst[i], m)
   }
}
```

And the output is:

```
Added 1, new median is 1
Added 2, new median is 1.5
Added 3, new median is 2
Added 4, new median is 2.5
Added 5, new median is 3
```
{'fraction_non_alphanumeric': 0.11502100840336134, 'fraction_numerical': 0.011554621848739496, 'mean_word_length': 3.4509345794392523, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6376494', 'n_tokens_mistral': 587, 'n_tokens_neox': 552, 'n_words': 260}