Update histogram examples

This commit is contained in:
Joseph T Lyons 2020-08-15 01:31:17 -04:00 committed by Andrés N. Robalino
parent d1d98a897a
commit 8f00713ad2
2 changed files with 64 additions and 64 deletions

View File

@ -20,13 +20,13 @@ Let's say we have this file `random_numers.csv` which contains 50 random numbers
────┬──────────────── ────┬────────────────
# │ random numbers # │ random numbers
────┼──────────────── ────┼────────────────
0 │ 1 0 │ 5
1 │ 2 1 │ 2
2 │ 2 2 │ 0
... ...
47 │ 5 47 │ 1
48 │ 5 48 │ 1
49 │ 1 49 │ 2
────┴──────────────── ────┴────────────────
``` ```
@ -34,59 +34,59 @@ If we now want to see how often the different numbers were generated, we can use
```shell ```shell
> open random_numbers.csv | histogram "random numbers" > open random_numbers.csv | histogram "random numbers"
───┬────────────────┬───────┬────────────────────────────────────────────────────────────────────────────────────────────────────── ───┬────────────────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ count │ frequency # │ random numbers │ occurrences │ percentage │ frequency
───┼────────────────┼───────┼────────────────────────────────────────────────────────────────────────────────────────────────────── ───┼────────────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
0 │ 0 │ 1 │ ****** 0 │ 0 │ 8 │ 57.14% *********************************************************
1 │ 1 │ 15**************************************************************************************************** 1 │ 1 │ 14 │ 100.00% ****************************************************************************************************
2 │ 2 │ 10 │ ****************************************************************** 2 │ 2 │ 9 │ 64.29% │ ****************************************************************
3 │ 3 │ 7 │ ********************************************** 3 │ 3 │ 6 │ 42.86% │ ******************************************
4 │ 4 │ 9 │ ************************************************************ 4 │ 4 │ 3 │ 21.43% │ *********************
5 │ 5 │ 8 │ ***************************************************** 5 │ 5 │ 10 │ 71.43% │ ***********************************************************************
───┴────────────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────── ───┴────────────────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
``` ```
We can also set the name of the second column or sort the table: We can also set the name of the second column or sort the table:
```shell ```shell
> open random_numbers.csv | histogram "random numbers" probability > open random_numbers.csv | histogram "random numbers" probability
───┬────────────────┬───────┬────────────────────────────────────────────────────────────────────────────────────────────────────── ───┬────────────────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ count │ probability # │ random numbers │ occurrences │ percentage │ probability
───┼────────────────┼───────┼────────────────────────────────────────────────────────────────────────────────────────────────────── ───┼────────────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
0 │ 0 │ 1 │ ****** 0 │ 0 │ 8 │ 57.14% *********************************************************
1 │ 1 │ 15**************************************************************************************************** 1 │ 1 │ 14 │ 100.00% ****************************************************************************************************
2 │ 2 │ 10 │ ****************************************************************** 2 │ 2 │ 9 │ 64.29% │ ****************************************************************
3 │ 3 │ 7 │ ********************************************** 3 │ 3 │ 6 │ 42.86% │ ******************************************
4 │ 4 │ 9 │ ************************************************************ 4 │ 4 │ 3 │ 21.43% │ *********************
5 │ 5 │ 8 │ ***************************************************** 5 │ 5 │ 10 │ 71.43% │ ***********************************************************************
───┴────────────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────── ───┴────────────────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
``` ```
```shell ```shell
> open random_numbers.csv | histogram "random numbers" probability | sort-by probability > open random_numbers.csv | histogram "random numbers" probability | sort-by probability
───┬────────────────┬───────┬────────────────────────────────────────────────────────────────────────────────────────────────────── ───┬────────────────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ count │ probability # │ random numbers │ occurrences │ percentage │ probability
───┼────────────────┼───────┼────────────────────────────────────────────────────────────────────────────────────────────────────── ───┼────────────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
0 │ 0 │ 1 │ ****** 0 │ 4 │ 3 │ 21.43% │ *********************
1 │ 3 │ 7 │ ********************************************** 1 │ 3 │ 6 │ 42.86% │ ******************************************
2 │ 5 │ 8 │ ***************************************************** 2 │ 0 │ 8 │ 57.14% │ *********************************************************
3 │ 4 │ 9 │ ************************************************************ 3 │ 2 │ 9 │ 64.29% │ ****************************************************************
4 │ 2 │ 10 │ ****************************************************************** 4 │ 5 │ 10 │ 71.43% │ ***********************************************************************
5 │ 1 │ 15**************************************************************************************************** 5 │ 1 │ 14 │ 100.00% ****************************************************************************************************
───┴────────────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────── ───┴────────────────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
``` ```
Of course, histogram operations are not restricted to just analyzing numbers in files, you can also analyze your directories Of course, histogram operations are not restricted to just analyzing numbers in files, you can also analyze your directories
```shell ```shell
> ls -la | histogram type | sort-by count > ls -la | histogram type | sort-by occurrences
───┬─────────┬───────┬────────────────────────────────────────────────────────────────────────────────────────────────────── ───┬─────────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ type │ count │ frequency # │ type │ occurrences │ percentage │ frequency
───┼─────────┼───────┼────────────────────────────────────────────────────────────────────────────────────────────────────── ───┼─────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
0 │ Symlink │ 8 │ ***************** 0 │ Dir │ 5 │ 4.76% │ ****
1 │ File │ 9 │ ******************** 1 │ Symlink │ 28 │ 26.67% │ **************************
2 │ Dir │ 45**************************************************************************************************** 2 │ File │ 105 │ 100.00% ****************************************************************************************************
───┴─────────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────── ───┴─────────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
``` ```

View File

@ -55,27 +55,27 @@ true
``` ```
```shell ```shell
> random dice --dice 1024 --sides 16 | histogram | sort-by count > random dice --dice 1024 --sides 16 | histogram | sort-by occurrences
────┬───────┬───────┬────────────────────────────────────────────────────────────────────────────────────────────────────── ────┬───────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ value │ count │ frequency # │ value │ occurrences │ percentage │ frequency
────┼───────┼───────┼────────────────────────────────────────────────────────────────────────────────────────────────────── ────┼───────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
0 │ 14 │ 54 │ ********************************************************************** 0 │ 6 │ 57 │ 75.00% │ ***************************************************************************
1 │ 4 │ 55 │ *********************************************************************** 1 │ 12 │ 59 │ 77.63% │ *****************************************************************************
2 │ 10 │ 58 │ *************************************************************************** 2 │ 3 │ 59 │ 77.63% │ *****************************************************************************
3 │ 15 │ 59 │ **************************************************************************** 3 │ 16 │ 60 │ 78.95% │ ******************************************************************************
4 │ 11 │ 60 │ ***************************************************************************** 4 │ 13 │ 61 │ 80.26% │ ********************************************************************************
5 │ 7 │ 60 │ ***************************************************************************** 5 │ 11 │ 62 │ 81.58% │ *********************************************************************************
6 │ 16 │ 61 │ ******************************************************************************* 6 │ 5 │ 62 │ 81.58% │ *********************************************************************************
7 │ 5 │ 62 │ ******************************************************************************** 7 │ 9 │ 62 │ 81.58% │ *********************************************************************************
8 │ 3 │ 63 │ ********************************************************************************* 8 │ 4 │ 63 │ 82.89% │ **********************************************************************************
9 │ 9 │ 63 │ ********************************************************************************* 9 │ 8 │ 64 │ 84.21% │ ************************************************************************************
10 │ 2 │ 64 │ *********************************************************************************** 10 │ 10 │ 65 │ 85.53% │ *************************************************************************************
11 │ 8 │ 68 │ **************************************************************************************** 11 │ 15 │ 66 │ 86.84% │ **************************************************************************************
12 │ 1 71 │ ******************************************************************************************** 12 │ 14 │ 67 │ 88.16% ****************************************************************************************
13 │ 13 │ 73 │ ********************************************************************************************** 13 │ 7 │ 69 │ 90.79% │ ******************************************************************************************
14 │ 6 │ 76 │ ************************************************************************************************** 14 │ 1 │ 72 │ 94.74% │ **********************************************************************************************
15 │ 12 │ 77**************************************************************************************************** 15 │ 2 │ 76 │ 100.00% ****************************************************************************************************
────┴───────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────── ────┴───────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
``` ```
## uuid ## uuid