pprobability {exams.forge}R Documentation

Polynomial Probability

Description

Creates for each value of a discrete random variable, a polynomial and estimates the least squares and the maximum likelihood solution. The following conditions stand:

Usage

pprobability(
  x,
  power = 1,
  zero = FALSE,
  coef = round(seq(-1, 1, by = 0.1), 1),
  sample = rep(1, length(x)),
  pl = NULL,
  tol = 1e-09
)

polynomial_probability(
  x,
  power = 1,
  zero = FALSE,
  coef = round(seq(-1, 1, by = 0.1), 1),
  sample = rep(1, length(x)),
  pl = NULL,
  tol = 1e-09
)

Arguments

x

numeric: values of a discrete random variable

power

integer: the degree for the polynomials (default: 1), must be larger 0

zero

logical: are zero coefficients and zero samples allowed? (default: FALSE)

coef

matrix: for each degree coefficients to sample from (default: seq(-1, 1, by=0.1))

sample

integer: number of x values in the sample or sample size (default: rep(1, length(x)))

pl

polylist: a list of polynomials which describes the probability for x (default: NULL)

tol

numeric: tolerance to detect zero values (default: 1e-9)

Value

A list with the components:

Examples

# linear polynomials
pprobability(0:2)
pprobability(0:2, power=1)
# constant polynomials, some NAs are generated
pprobability(0:3, power=0)
# polynomials generated from a different set
pprobability(0:2, coef=seq(-2, 2, by=0.1))
pprobability(0:2, 0, coef=seq(-2, 2, by=0.1))
# polynomials (x, x, 1-2*x) are used
pprobability(0:2, 0, coef=matrix(c(0.4, 0.4, 0.3), ncol=3))
pprobability(0:2, 1, coef=polylist(c(0,1), c(0,1), c(1, -2)))

[Package exams.forge version 1.0.10 Index]