Stat.pm untested

filter: Statementstmt 0.0% 0 / 1 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 1 SCAR -
1 package Catmandu::Stat;
2  
3 =head1 NAME
4  
5 Catmandu::Stat - Catmandu modules for working with statistical data
6  
7 =cut
8  
9 our $VERSION = '0.13';
10  
11 =head1 SYNOPSIS
12  
13 # Calculate statistics on the availabity of the ISBN fields in the dataset
14 cat data.json | catmandu convert JSON to Stat --fields isbn
15  
16 # Preprocess data and calculate statistics
17 catmandu convert MARC to Stat --fix 'marc_map(020a,isbn)' --fields isbn < data.mrc
18  
19 # Or in fix files
20  
21 # Calculate the mean of foo. E.g. foo => [1,2,3,4]
22 stat_mean(foo) # foo => '2.5'
23  
24 # Calculate the median of foo. E.g. foo => [1,2,3,4]
25 stat_median(foo) # foo => '2.5'
26  
27 # Calculate the standard deviation of foo. E.g. foo => [1,2,3,4]
28 stat_stddev(foo) # foo => '1.12'
29  
30 # Calculate the variance of foo. E.g. foo => [1,2,3,4]
31 stat_variance(foo) # foo => '1.25'
32  
33 =head1 MODULES
34  
35 =over
36  
37 =item * L<Catmandu::Exporter::Stat>
38  
39 =item * L<Catmandu::Fix::stat_mean>
40  
41 =item * L<Catmandu::Fix::stat_median>
42  
43 =item * L<Catmandu::Fix::stat_stddev>
44  
45 =item * L<Catmandu::Fix::stat_variance>
46  
47 =back
48  
49 =head1 EXAMPLES
50  
51 The Catmandu::Stat distribution includes a CSV file on the Sacramento crime rate in January 2006,
52 "t/SacramentocrimeJanuary2006.csv" also available at
53 http://samplecsvs.s3.amazonaws.com/SacramentocrimeJanuary2006.csv
54  
55 To view statistics on the fields available in this file type:
56  
57 $ catmandu convert CSV to Stat < t/SacramentocrimeJanuary2006.csv
58  
59 | name | count | zeros | zeros% | min | max | mean | variance | stdev | uniq~ | uniq% | entropy |
60 |---------------|-------|-------|--------|-----|-----|------|----------|-------|-------|-------|-----------|
61 | # | 7584 | | | | | | | | | | |
62 | address | 7584 | 0 | 0.0 | 1 | 1 | 1 | 0.0 | 0.0 | 5425 | 71.5 | 12.4/12.4 |
63 | beat | 7584 | 0 | 0.0 | 1 | 1 | 1 | 0.0 | 0.0 | 20 | 0.3 | 4.3/12.9 |
64 | cdatetime | 7584 | 0 | 0.0 | 1 | 1 | 1 | 0.0 | 0.0 | 5071 | 66.9 | 12.3/12.3 |
65 | crimedescr | 7584 | 0 | 0.0 | 1 | 1 | 1 | 0.0 | 0.0 | 305 | 4.0 | 5.6/12.6 |
66 | district | 7584 | 0 | 0.0 | 1 | 1 | 1 | 0.0 | 0.0 | 6 | 0.1 | 2.6/12.9 |
67 | grid | 7584 | 0 | 0.0 | 1 | 1 | 1 | 0.0 | 0.0 | 537 | 7.1 | 7.8/9.9 |
68 | latitude | 7584 | 0 | 0.0 | 1 | 1 | 1 | 0.0 | 0.0 | 5288 | 69.7 | 12.4/12.4 |
69 | longitude | 7584 | 0 | 0.0 | 1 | 1 | 1 | 0.0 | 0.0 | 5295 | 69.8 | 12.4/12.4 |
70 | ucr_ncic_code | 7584 | 0 | 0.0 | 1 | 1 | 1 | 0.0 | 0.0 | 88 | 1.2 | 4.1/12.9 |
71  
72 The file has 7584 rows where and all the fields C<address> to C<ucr_ncic_code> contain values.
73 Each field has only one value (no arrays available in the CSV file). The are 5492 unique
74 addresses in the CSV file. The C<district> field has the lowest entropy, most of its values are
75 shared among many rows.
76  
77  
78 =head1 SEE ALSO
79  
80 L<Catmandu>,
81 L<Catmandu::Breaker>,
82  
83 =head1 AUTHOR
84  
85 Patrick Hochstenbach, C<< <patrick.hochstenbach at ugent.be> >>
86  
87 =head1 LICENSE AND COPYRIGHT
88  
89 This program is free software; you can redistribute it and/or modify it
90 under the terms of either: the GNU General Public License as published
91 by the Free Software Foundation; or the Artistic License.
92  
93 See http://dev.perl.org/licenses/ for more information.
94  
95 =cut
96  
97 1;