Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sample_spc

Incremental Samples from a Frequency Spectrum (zipfR)


Description

Compute incremental random samples from a frequency spectrum (an object of class spc).

Usage

sample.spc(obj, N, force.list=FALSE)

Arguments

obj

an object of class spc, representing a frequency spectrum

N

a vector of non-negative integers in increasing order, the sample sizes for which incremental samples will be generated

force.list

if TRUE, the return value will always be a list of spc objects, even if N is just a single integer

Details

This function is currently implemented as a wrapper around sample.tfl, using spc2tfl and tfl2spc to convert between frequency spectra and type frequency lists. A direct implementation might be slightly more efficient, but would very likely not make a substantial difference.

Value

If N is a single integer (and the force.list flag is not set), a spc object representing the frequency spectrum of a random sample of size N from obj.

If N is a vector of length greater one, or if force.list=TRUE, a list of spc objects representing the frequency spectra of incremental random samples of the specified sizes N. Incremental means that each sample is a superset of the preceding sample.

See Also

spc for more information about frequency spectra

sample.tfl is an analogous function for type frequency lists (objects of class tfl)

sample.spc takes a single concrete random subsample from a spectrum and returns the spectrum of the subsample, unlike spc.interp, that computes the expected frequency spectrum for random subsamples of size N by binomial interpolation.

Examples

## read Brown spectrum
data(Brown.spc)
summary(Brown.spc)

## sample a spectrum of 100k tokens
MiniBrown.spc <- sample.spc(Brown.spc,1e+5)
summary(MiniBrown.spc)

## if we repat, we get a different sample
MiniBrown.spc <- sample.spc(Brown.spc,1e+5)
summary(MiniBrown.spc)

zipfR

Statistical Models for Word Frequency Distributions

v0.6-70
GPL-3
Authors
Stefan Evert <stefan.evert@fau.de>, Marco Baroni <marco.baroni@unitn.it>
Initial release
2020-10-10

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.