Previous Page Next Page Contents

stats::sample -- the domain of statistical samples

Introduction

A sample represents a collection of statistical data, organized as a matrix. Usually, each row refers to an individual of the population described by the sample. Each column represents an attribute.

Introduction

stats::sample([[a11, ..., a1.n], ..., [a.m.1, ..., a.m.n]]) creates a sample with m rows and n columns, a.i.j being the entry in the i-th row, j-th column.

stats::sample([a11, ..., a.m.1]) creates a sample with m rows and one column.

Creating Elements

stats::sample([[a11, a12, ...], [a21, a22, ...], ...])
stats::sample([a11, a21, ...])

Parameters

a11, a12, ... - arithmetical expressions or strings.

Categories

Cat::Set

Details

Method equal: test for equality

Method convert: convert a list to a sample

Method convert_to: convert a sample to a list of lists

Method expr: convert a sample to a list of lists of expressions

Method col2list: return a particular column as a list

Method append: append a row

Method _concat: create a sample from the rows of several samples

Method delCol: delete one or more columns

Method delRow: delete one or more rows

Method float: map the float function to all entries

Method has: test for the occurrence of elements

Method _index: return a particular entry

Method set_index: assign a new value to an entry

Method map: map a function to the rows

Method nops: number of rows

Method op: get the operands (rows)

Method subsop: replace a row

Method row2list: return a particular row as a list

Method print: output

Method fastprint: fast output

Example 1

A sample is created from a list of rows:

>> stats::sample([[5, a], [b, 7.534], [7/4, c+d]])
                                 5      a
                                 b  7.534
                               7/4  c + d

For a sample with only one column one can use a flat list instead of a list of rows:

>> stats::sample([5, 3, 8])
                                    5
                                    3
                                    8

Example 2

The following input creates a small sample with columns for ``gender'', ``age'' and ``height'', respectively:

>> stats::sample([["m", 26, 180], ["f", 22, 160], 
                  ["f", 48, 155], ["m", 30, 172]])
                              "m"  26  180
                              "f"  22  160
                              "f"  48  155
                              "m"  30  172

Note that all entries in a column are automatically converted to strings, if one entry of that column is a string:

>> stats::sample([[m, 26, 180], [f, 22, 160], 
                  ["f", 48, 155], [m, 30, 172]])
                              "m"  26  180
                              "f"  22  160
                              "f"  48  155
                              "m"  30  172

Example 3

The functions float, has, map, nops, op, and subsop are overloaded to work on samples as on lists of lists:

>> s := stats::sample([[a, 1], [b, 2], [c, 3]])
                                  a  1
                                  b  2
                                  c  3
>> float(s), has(s, a), map(s, list -> [list[1], list[2]^2]),
   nops(s), subsop(s, 1 = [d, 4]), op(s, [1, 2])
                   a  1.0  , TRUE, a  1  , 3, d  4  , 1
                   b  2.0          b  4       b  2
                   c  3.0          c  9       c  3

Indexing works like on arrays:

>> s[1, 2] := x : s
                                  a  x
                                  b  2
                                  c  3
>> delete s:

Example 4

The dot operator may be used to concatenate samples and lists (regarded a samples with one row):

>> s := stats::sample([[1, a], [2, b]]): s.[X, Y].s
                                  1  a
                                  2  b
                                  X  Y
                                  1  a
                                  2  b
>> delete s:

Super-Domain

Dom::BaseDomain

Axioms

Ax::canonicalRep

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000