Computes a random subsample of a dataset.
exctsmpl(infile, outfile, percent)¶
- infile (string) – the name of the original dataset.
- outfile (string) – the name of the dataset to be created.
- percent (scalar) – the percentage random sample to take. This must be in the range 0-100.
n_rows (scalar) –
number of rows in output dataset.
Error returns are controlled by the low bit of the
terminate with error message
return scalar negative integer -1 can’t open input file -2 can’t open output file -3 disk full
// Create file name with full path fname = getGAUSSHome()$+ "examples/credit.dat"; // Randomly sample 30% of the rows from 'credit.dat' // and write them to a new dataset in the // GAUSS working directory, named 'sample.dat' n_rows = exctsmpl(fname, "sample.dat", 30);
Random sampling is done with replacement. Thus, an observation may be in the resulting sample more than once. If percent is 100, the resulting sample will not be identical to the original sample, though it will be the same size.