next | previous | forward | backward | up | top | index | toc | Macaulay2 website
RandomMonomialIdeals :: sample

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
o2 = {{x x }, {x , x x }, {x , x x }, {x , x }}
        1 2     1   2 3     2   1 3     1   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
            Data => {{x x }, {x , x x }, {x , x x }, {x , x }}
                       1 2     1   2 3     2   1 3     1   2

and one can easily obtain sample statistics:

i4 : statistics(s,degree@@ideal)

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

o4 : HashTable

See also

Ways to use sample :

For the programmer

The object sample is a method function.