<<

Contents

Search

>>

 

RANDOM_SAMPLE$

 

 

Function

 

 

Syntax:

RANDOM_SAMPLE$(<Range>,<Numbers>,<Put back>,<Sort>)

 

<Range>

= <NUM-EXPRESSION>

<Numbers>

= <NUM-EXPRESSION>

<Put back>

= <NUM-EXPRESSION>

<Sort>

= <NUM-EXPRESSION>

 

 

Meaning:

Creates a random sample of a range of numbers.

 

<Range> specifies the quantity of numbers from 1 to <Range>.

 

<Numbers> specifies the amount of numbers to draw.

 

If <Put back> <> 0, drawed numbers are put back. Numbers can be drawn multiple.

If <Put back> = 0, drawed numbers are not put back. Numbers can be drawn only once.

 

If <Sort> > 0, the sample space is sorted ascending.

If <Sort> < 0, the sample space is sorted descending.

 

RANDOM_SAMPLE$ returns the drawn numbers separated by ";".

 

RANDOM_SAMPLE$ returns the following error codes:

"-1": <Numbers> < 1

"-2": <Numbers> > <Range> and <Put back> = 0.

 

Parameter:

Range

specifies the quantity of numbers from 1 to <Range>.

 

Numbers

amount of numbers to draw

 

Put back

= 0: drawn numbers are not put back.

<> 0: drawn numbers are put back.

 

Sort

> 0: the sample space is sorted ascending

< 0: the sample space is sorted descending

= 0: the sample space is not sorted

 

Sample:

LOTTERY_NUMBERS$ = RANDOM_SAMPLE$(49,6,0,1)

IF VAL(LOTTERY_NUMBERS$) < 0

THEN ... Error ...

ELSE /* LOTTERY_NUMBERS$ contains e.g. 4;8;23;36;48;49

ENDIF

 

See also:

RANDOMIZE

RND