Macaulay2 » Documentation
Packages » RandomMonomialIdeals :: statistics
next | previous | forward | backward | up | index | toc

statistics -- generate statistics for a sample

Synopsis

Description

This function generates statistics for the sample by applying the given function to each sample point and computing some basic summary statistics. Specifically, the function $f$ is applied to each element in the sample, and -- provided that the function has output of type either numerical (ZZ) or BettiTally -- its result is then used to calculate a mean, standard deviation, and a histogram.

i1 : s=sample(ER(6,3,0.2),15);
i2 : statistics(s, degree@@ideal)

o2 = HashTable{Histogram => Tally{1 => 4 }}
                                  2 => 3
                                  3 => 2
                                  4 => 3
                                  5 => 1
                                  10 => 1
                                  15 => 1
                       58
               Mean => --
                       15
               StdDev => 3.72141

o2 : HashTable

The output above shows the histogram of the degrees of ideals in the sample, as well as mean degree and its standard deviation. The same kind of output is produced by the following statistics:

i3 : s=sample(ER(2,2,0.8),10)

o3 = Sample{...4...}

o3 : Sample
i4 : statistics(s,betti@@gens@@ideal)

                                         0 1
o4 = HashTable{Histogram => Tally{total: 1 3 => 1}}
                                      0: 1 2
                                      1: . 1
                                         0 1
                                  total: 1 3 => 3
                                      0: 1 1
                                      1: . 2
                                         0 1
                                  total: 1 4 => 2
                                      0: 1 1
                                      1: . 3
                                         0 1
                                  total: 1 5 => 4
                                      0: 1 2
                                      1: . 3
                              0   1
               Mean => total: 1   4
                           0: 1 1.5
                           1: . 2.5
                                      1
               StdDev => total: 1.17082
                             0:      .5
                             1:  .67082

o4 : HashTable

In the example above, the entry Mean is the average - entry-wise - of the Betti tables of the random ideals in the sample. An adventurous user my wish to get statistics of other functions applied to the sample. If the output of f is not ZZ or BettiTally, the method will tally the sample data:

i5 : statistics(s,mingens@@ideal)
Warning: the statistics method is returning only the Tally of the outputs of 
		your function applied to the sample data. If you want more information, such as mean and 
		standard deviation, then ensure you use a function with numerical (ZZ) or BettiTally output.

o5 = Tally{| x_1 x_2^2 | => 3}
           | x_2 | => 1
           | x_2 x_1 | => 5
           | x_2 x_1^2 | => 1

o5 : Tally

Caveat

In fact, anything that can be run through "tally" can be used as the input function f to this method.

Ways to use statistics :

For the programmer

The object statistics is a method function.