https://github.com/boppreh/carlo
Interactively plot streaming sequences of numbers
https://github.com/boppreh/carlo
Last synced: 2 months ago
JSON representation
Interactively plot streaming sequences of numbers
- Host: GitHub
- URL: https://github.com/boppreh/carlo
- Owner: boppreh
- License: mit
- Created: 2021-09-23T22:51:32.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-25T13:35:32.000Z (over 2 years ago)
- Last Synced: 2025-03-25T13:45:59.595Z (3 months ago)
- Language: Python
- Size: 277 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# carlo
Named after the Monte Carlo algorithm, this module displays interactive histograms of streaming/online data. It's meant for quickly visualizing distributions, and it'll keep refining its histogram as new data comes in.
Accepts lists, generators, numbers from stdin, or a function to be repeatdly evaluated. Displays data as histograms with automagic bin allocation, and extra statistics in legends.
Note the bins will continually update as more data comes in, adjusting number and range to display the whole distribution. Care is taken to maintain the exact counts correct when redistributing the bins, without actually storing the samples in memory.
## Example 1
Compare samples from one 20-sided dice vs three 6-sided dices.
Imported:
```python
from carlo import plot, d
plot(lambda: d(20), lambda: d(6)+d(6)+d(6))
```Or as standalone module (where `d(n)` simulates the roll of a `n`-sided dice):
```bash
carlo "d(20)" "d(6)+d(6)+d(6)"
```
## Example 2
Sample values from `max(0.5, random()**0.2)`.
Imported:
```python
from carlo import plot
from random import random
plot(lambda: max(0.5, random()**0.2))
```Or as standalone module (all functions from the `random` module are automatically available).
```bash
carlo "max(0.5, random()**0.2)"
```
