xtrand

Section: User Commands (1)
Updated: 2002-10-26
Index Return to Main Contents

 

NAME

xtrand - generate randomized number

 

SYNOPSIS

xtrand -a new attribute [-k key attribute(s)] [-S random seed] [-M minimum value of random number] [-C types of distinct random number] [-q] [-i INPUT] [-o OUTPUT] [-z] [-t] [-T TEMP DIRECTORY]

 

DESCRIPTION

This command generates an integral random number and stored as a new attribute at parameter -a. With -k parameter, records with the same key value will be assigned the same random number. The range of a random number is given by [min, max], where min is given by -N and max-min+1 is given by -C. When -N and -C are omitted, min=0 and max=RND_MAX are assumed. When -S is omitted, random seed is determined by the current time.

 

PARAMETERS

-k key attribute(s)
the base unit on which the random number is generated for (when -k is omitted, all lines are assumed to take the distinct key value). -S random seed random seed (from 1 to maximum value of int type) -M minimum value of random number specify the minimum value of random number -C types of distinct random number specify the types of distinct random numbers
-a new attribute
define the name for the new attribute
-q sequential processing
when this option is used with the -k parameter, the command processes the input data in original sequence of the records, instead of sorting by the key attribut e -k.

 

FILE OPTIONS

-i input filename
if a suffix of the filename is '.gz', the command acts as a filter, extracting the compressed file for processing. The command will read the file as standard input when "-i" is not specified.
-o output filename
if a suffix of the filename is '.gz', the command automatically returns the output data in zip archive. When "-o" is not specified, the result will sent to standard output.
-z zip archive
compress the standard output to zip archive. When the option "-o" is not given and "-z" is specified, the output will be compressed as zip archive.
-t plain text
xtagg treats the input and output data as plain text format.

 

USAGE

Input file - dat.xt:
<field no="1">
<name>CustomerID</name>
</field>
<field no="2">
<name>Date</name>
</field>
<field no="3">
<name>TotalQuantity</name>
</field>
<field no="4">
<name>TotalAmount</name>
</field>
<body><![CDATA[
A00004 20020214 1 365
A00004 20020415 5 4349
A00004 20020625 3 5268
A00004 20020810 2 1805
A00004 20021014 2 612
A00004 20021016 11 3410
A00005 20020918 12 4554
A00005 20020923 1 491
A00006 20020606 3 1364
A00006 20020918 5 2195
]]></body>

Example 1. Generate a random number for each record. e.g. xtrand -a random_number -i dat.xt -o rsl.xt Output file -rsl.xt

<body><![CDATA[
A00004 20020214 1 365 406763383
A00004 20020415 5 4349 1648165027
A00004 20020625 3 5268 543803879
A00004 20020810 2 1805 1523050550
A00004 20021014 2 612 463290392
A00004 20021016 11 3410 985412327
A00005 20020918 12 4554 1100770079
A00005 20020923 1 491 22543184
A00006 20020606 3 1364 1541605009
A00006 20020918 5 2195 342093485
]]></body>

Example 2. Generate a random number for each customer. e.g. xtrand -k CustomerID -a randome_number -i dat.xt -o rsl.xt Output file -rsl.xt

<body><![CDATA[
A00004 20020214 1 365 1881555469
A00004 20020415 5 4349 1881555469
A00004 20020625 3 5268 1881555469
A00004 20020810 2 1805 1881555469
A00004 20021014 2 612 1881555469
A00004 20021016 11 3410 1881555469
A00005 20020918 12 4554 719314905
A00005 20020923 1 491 719314905
A00006 20020606 3 1364 1614308332
A00006 20020918 5 2195 1614308332
]]></body>

Example 2. Generate a random number with seed 10 for each customer. e.g. xtrand -a randome_number -S 10 -i dat.xt -o rsl.xt Output file -rsl.xt

<body><![CDATA[
A00004 20020214 1 365 1311962007
A00004 20020415 5 4349 1086128677
A00004 20020625 3 5268 385788725
A00004 20020810 2 1805 1753820417
A00004 20021014 2 612 394002377
A00004 20021016 11 3410 1255532674
A00005 20020918 12 4554 906573271
A00005 20020923 1 491 54404747
A00006 20020606 3 1364 679162307
A00006 20020918 5 2195 131589623
]]></body>

 

SEE ALSO

xtcal(1) For complete documentation and tutorial of xtrand and other commands, please visit http://musashien.sourceforge.net

 

BUG REPORT

If you find a bug in xtrand, please send an electronic mail to musashi@adm.osaka-sandai.ac.jp. Before sending a bug report, please verify that you have the lastest version of MUSASHI. Read this manual carefully to ensure the error is not caused by a quirk in the language.

 

AUTHORS

Yukinobu Hamuro, Naoki Katoh, Katsutoshi Yada, Stephane Cheung


 

Index

NAME
SYNOPSIS
DESCRIPTION
PARAMETERS
FILE OPTIONS
USAGE
SEE ALSO
BUG REPORT
AUTHORS

This document was created by man2html, using the manual pages.
Time: 22:43:55 GMT, June 24, 2003