ros: Generate Random Data from Order Statistics

View source: R/functions.R

rosR Documentation

Generate Random Data from Order Statistics

Description

This function generates random data from the order statistics of a specified distribution. The user can specify a known distribution in R or provide a custom quantile function.

Usage

ros(size, r, n, dist = NULL, qf = NULL, ...)

Arguments

size

number of observations.

r

rank(s) of the desired order statistic(s) (e.g., 1 for the smallest order statistic).

n

sample size from which the order statistic is derived.

dist

a character string specifying the name of a known distribution in R (e.g. 'norm', 'exp'). Default is NULL.

qf

a custom quantile function, either as a name (string) or directly as a function. Default is NULL.

...

further arguments to be passed to dist or qf.

Details

The ros function generates random data from order statistics using two approaches:

  1. Using a Known Distribution: When dist is provided, random data is generated from a known distribution in R.

  2. Using a Custom Quantile Function: When qf is provided, ros applies the user-provided quantile function to generate random data.

Value

A numeric vector or matrix containing the generated random data from the specified order statistics. If a single rank is provided (i.e., scalar r), a numeric vector of size size is returned. If multiple ranks are provided (i.e., vector r), a matrix is returned with size rows and length(r) columns, where each row corresponds to a simulation and each column to an order statistic.

Examples

# Example 1: Generate from the normal distribution
ros(5, 3, 15, "norm", mean = 4, sd = 2)

# Example 2: Using a custom quantile function for the Pareto distribution
ros(3, 2, 10, qf = function(p, scale, shape) scale * (1 - p)^(-1 / shape), scale = 3, shape = 2)

# Example 3: Generate multiple order statistics from the uniform distribution
# In this example, first through 5th order statistics are generated from a sample size of 5.
ros(3, 1:5, 5, dist = "unif")


mos documentation built on June 16, 2025, 5:09 p.m.