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

sample -- generates a sample from the given model

Synopsis

Description

This function generates $N$ realizations of the random variable that has the distribution specified by the given model.

i1 : s=sample(ER(3,2,0.2),4)

o1 = Sample{...4...}

o1 : Sample

One obtains the data from the object of type Sample (that is, the actual sample in the statistical sense) as follows:

i2 : getData s

            2   2     2           2         2               2
o2 = {{x , x , x }, {x }, {x x , x , x x , x }, {x , x x , x }}
        3   2   3     2     1 3   2   2 3   3     1   1 2   2

o2 : List

The actual sample contains more information than just the data itself:

i3 : peek s

o3 = Sample{ModelName => Erdos-Renyi                                          }
            Parameters => (3, 2, .2)
            SampleSize => 4
                           2   2     2           2         2               2
            Data => {{x , x , x }, {x }, {x x , x , x x , x }, {x , x x , x }}
                       3   2   3     2     1 3   2   2 3   3     1   1 2   2

and one can easily obtain sample statistics:

i4 : statistics(s,degree@@ideal)

o4 = HashTable{Histogram => Tally{2 => 4}}
               Mean => 2
               StdDev => 0

o4 : HashTable

See also

Ways to use sample:

For the programmer

The object sample is a method function.