# sample -- generates a sample from the given model

## Synopsis

• Usage:
sample(Model,ZZ)
• Inputs:
• M, an instance of the type Model, to be sampled from
• N, an integer, sample size
• Outputs:
• an instance of the type Sample, a sample of size $N$ from the given model $M$

## 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

 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