MoTBF-Distribution: Random generation for MoTBF distributions

MoTBF-DistributionR Documentation

Random generation for MoTBF distributions

Description

Random generation for mixtures of truncated basis functions defined in a specific domain. The inverse transform method is used.

Usage

rMoTBF(size, fx, domain = NULL)

inversionMethod(size, fx, domain = NULL, data = NULL)

Arguments

size

A non-negative integer indicating the number of records to generate.

fx

An object of class "motbf".

domain

A "numeric" vector indicating the lower and upper limits to sample from. If not specified, the range is taken from the object fx.

data

A "numeric" vector to be compared with the simulated sample. By default, it is NULL; otherwise, the empirical cumulative distributions of both the data and the simulated sample are plotted and the Kolmogorov Smirnov test is used to test whether or not both samples can be considered to be drawn from the same distribution.

Value

rMoTBF() returns a "numeric" vector containing the simulated values. inversionMethod() returns a list with the simulated values and the results of the two-sample Kolmogorov-Smirnov test, as well as the plot of the CDFs of the original and simulated data.

See Also

integralMoTBF

Examples


## 1. EXAMPLE
## Data
X <- rnorm(1000, mean = 5, sd = 3)

## Learning
f <- univMoTBF(X, POTENTIAL_TYPE="MOP", nparam=10)
plot(f, xlim = f$Domain)

## Random sample
Y <- rMoTBF(size = 500, fx = f)
ks.test(X,Y)

## Plots
hist(Y, prob = TRUE, add = TRUE)

## 2. EXAMPLE 
## Data
X <- rweibull(5000, shape=2)

## Learning
f <- univMoTBF(X, POTENTIAL_TYPE="MOP", nparam=10)
plot(f, xlim = f$Domain)

## Random sample
inv <- inversionMethod(size = 500, fx = f, data = X)
attributes(inv)
inv$test
Y <- inv$sample 

## Plots
plot(f, xlim = f$Domain)
hist(Y, prob = TRUE, add = TRUE)


MoTBFs documentation built on April 18, 2022, 5:06 p.m.