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
────┼────────────────
01
05
12
22
20
...
475
485
491
471
481
492
────┴────────────────
```
@ -34,59 +34,59 @@ If we now want to see how often the different numbers were generated, we can use
```shell
> open random_numbers.csv | histogram "random numbers"
───┬────────────────┬───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ count │ frequency
───┼────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
001******
1115 │ ****************************************************************************************************
2210 │ ******************************************************************
337 │ **********************************************
449 │ ************************************************************
558*****************************************************
───┴────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
───┬────────────────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ occurrences │ percentage │ frequency
───┼────────────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
00 8 │ 57.14% │ *********************************************************
11 14 │ 100.00% │ ****************************************************************************************************
22 9 │ 64.29% │ ****************************************************************
33 6 │ 42.86% │ ******************************************
44 3 │ 21.43% │ *********************
55 10 │ 71.43% │ ***********************************************************************
───┴────────────────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
```
We can also set the name of the second column or sort the table:
```shell
> open random_numbers.csv | histogram "random numbers" probability
───┬────────────────┬───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ count │ probability
───┼────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
001******
1115 │ ****************************************************************************************************
2210 │ ******************************************************************
337 │ **********************************************
449 │ ************************************************************
558*****************************************************
───┴────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
───┬────────────────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ occurrences │ percentage │ probability
───┼────────────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
00 8 │ 57.14% │ *********************************************************
11 14 │ 100.00% │ ****************************************************************************************************
22 9 │ 64.29% │ ****************************************************************
33 6 │ 42.86% │ ******************************************
44 3 │ 21.43% │ *********************
55 10 │ 71.43% │ ***********************************************************************
───┴────────────────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
```
```shell
> open random_numbers.csv | histogram "random numbers" probability | sort-by probability
───┬────────────────┬───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ count │ probability
───┼────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
001******
137 │ **********************************************
258*****************************************************
349************************************************************
4210 │ ******************************************************************
5115 │ ****************************************************************************************************
───┴────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
───┬────────────────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ occurrences │ percentage │ probability
───┼────────────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
04 3 │ 21.43% │ *********************
13 6 │ 42.86% │ ******************************************
20 8 │ 57.14% │ *********************************************************
32 9 │ 64.29% │ ****************************************************************
45 1071.43% │ ***********************************************************************
51 14 │ 100.00% │ ****************************************************************************************************
───┴────────────────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
```
Of course, histogram operations are not restricted to just analyzing numbers in files, you can also analyze your directories
```shell
> ls -la | histogram type | sort-by count
───┬─────────┬───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ type │ count │ frequency
───┼─────────┼───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
0Symlink │ 8 │ *****************
1File 9 │ ********************
2Dir 45 │ ****************************************************************************************************
───┴─────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
> ls -la | histogram type | sort-by occurrences
───┬─────────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ type │ occurrences │ percentage │ frequency
───┼─────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
0Dir │ 5 │ 4.76% │ ****
1Symlink │ 2826.67% │ **************************
2File 105 │ 100.00% │ ****************************************************************************************************
───┴─────────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
```

View File

@ -55,27 +55,27 @@ true
```
```shell
> random dice --dice 1024 --sides 16 | histogram | sort-by count
────┬───────┬───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ value │ count │ frequency
────┼───────┼───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
01454 │ **********************************************************************
14 55 │ ***********************************************************************
21058 │ ***************************************************************************
31559 │ ****************************************************************************
41160 │ *****************************************************************************
57 60 │ *****************************************************************************
61661 │ *******************************************************************************
7562 │ ********************************************************************************
8363 │ *********************************************************************************
9963 │ *********************************************************************************
102 64 │ ***********************************************************************************
118 68 │ ****************************************************************************************
121 71 │ ********************************************************************************************
131373 │ **********************************************************************************************
14676**************************************************************************************************
151277 │ ****************************************************************************************************
────┴───────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
> random dice --dice 1024 --sides 16 | histogram | sort-by occurrences
────┬───────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ value │ occurrences │ percentage │ frequency
────┼───────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
06 5775.00% │ ***************************************************************************
112 5977.63% │ *****************************************************************************
23 5977.63% │ *****************************************************************************
316 60 │ 78.95% │ ******************************************************************************
413 6180.26% │ ********************************************************************************
511 6281.58% │ *********************************************************************************
65 62 │ 81.58% │ *********************************************************************************
79 6281.58% │ *********************************************************************************
84 6382.89% │ **********************************************************************************
98 6484.21% │ ************************************************************************************
1010 6585.53% │ *************************************************************************************
1115 66 │ 86.84% │ **************************************************************************************
1214 67 │ 88.16% │ ****************************************************************************************
137 69 │ 90.79% │ ******************************************************************************************
141 7294.74% │ **********************************************************************************************
152 76 │ 100.00% │ ****************************************************************************************************
────┴───────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
```
## uuid