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
────┼──────────────── ────┼────────────────
01 05
12 12
22 20
... ...
475 471
485 481
491 492
────┴──────────────── ────┴────────────────
``` ```
@ -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
───┼────────────────┼───────┼────────────────────────────────────────────────────────────────────────────────────────────────────── ───┼────────────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
001****** 00 8 │ 57.14% │ *********************************************************
1115 │ **************************************************************************************************** 11 14 │ 100.00% │ ****************************************************************************************************
2210 │ ****************************************************************** 22 9 │ 64.29% │ ****************************************************************
337 │ ********************************************** 33 6 │ 42.86% │ ******************************************
449 │ ************************************************************ 44 3 │ 21.43% │ *********************
558***************************************************** 55 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
───┼────────────────┼───────┼────────────────────────────────────────────────────────────────────────────────────────────────────── ───┼────────────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
001****** 00 8 │ 57.14% │ *********************************************************
1115 │ **************************************************************************************************** 11 14 │ 100.00% │ ****************************************************************************************************
2210 │ ****************************************************************** 22 9 │ 64.29% │ ****************************************************************
337 │ ********************************************** 33 6 │ 42.86% │ ******************************************
449 │ ************************************************************ 44 3 │ 21.43% │ *********************
558***************************************************** 55 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
───┼────────────────┼───────┼────────────────────────────────────────────────────────────────────────────────────────────────────── ───┼────────────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
001****** 04 3 │ 21.43% │ *********************
137 │ ********************************************** 13 6 │ 42.86% │ ******************************************
258***************************************************** 20 8 │ 57.14% │ *********************************************************
349************************************************************ 32 9 │ 64.29% │ ****************************************************************
4210 │ ****************************************************************** 45 1071.43% │ ***********************************************************************
5115 │ **************************************************************************************************** 51 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
───┼─────────┼───────┼────────────────────────────────────────────────────────────────────────────────────────────────────── ───┼─────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
0Symlink │ 8 │ ***************** 0Dir │ 5 │ 4.76% │ ****
1File 9 │ ******************** 1Symlink │ 2826.67% │ **************************
2Dir 45 │ **************************************************************************************************** 2File 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
────┼───────┼───────┼────────────────────────────────────────────────────────────────────────────────────────────────────── ────┼───────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
01454 │ ********************************************************************** 06 5775.00% │ ***************************************************************************
14 55 │ *********************************************************************** 112 5977.63% │ *****************************************************************************
21058 │ *************************************************************************** 23 5977.63% │ *****************************************************************************
31559 │ **************************************************************************** 316 60 │ 78.95% │ ******************************************************************************
41160 │ ***************************************************************************** 413 6180.26% │ ********************************************************************************
57 60 │ ***************************************************************************** 511 6281.58% │ *********************************************************************************
61661 │ ******************************************************************************* 65 62 │ 81.58% │ *********************************************************************************
7562 │ ******************************************************************************** 79 6281.58% │ *********************************************************************************
8363 │ ********************************************************************************* 84 6382.89% │ **********************************************************************************
9963 │ ********************************************************************************* 98 6484.21% │ ************************************************************************************
102 64 │ *********************************************************************************** 1010 6585.53% │ *************************************************************************************
118 68 │ **************************************************************************************** 1115 66 │ 86.84% │ **************************************************************************************
121 71 │ ******************************************************************************************** 1214 67 │ 88.16% │ ****************************************************************************************
131373 │ ********************************************************************************************** 137 69 │ 90.79% │ ******************************************************************************************
14676************************************************************************************************** 141 7294.74% │ **********************************************************************************************
151277 │ **************************************************************************************************** 152 76 │ 100.00% │ ****************************************************************************************************
────┴───────┴───────┴────────────────────────────────────────────────────────────────────────────────────────────────────── ────┴───────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
``` ```
## uuid ## uuid