probability: Probability

View source: R/deepUtils.r

probabilityR Documentation

Probability

Description

Probability

Usage

probability(x, ...)

## S3 method for class 'character'
probability(x, y, laplace = 0)

## S3 method for class 'factor'
probability(x, y, laplace = 0)

## S3 method for class 'logical'
probability(x, y, laplace = 0)

## S3 method for class 'numeric'
probability(x, FUN, ...)

Arguments

x

A scalar or vector the probability is calculated for.

...

Optional arguments to FUN.

y

A factor variable the probability distribution is calculated to get the probability of a categorical x.

laplace

A value for Laplace smoothing to avoid zero probability problem, default 0 is equal to no smoothing.

FUN

The function to be applied to compute the probability distribution. If no function is specified, gaussian distribution density function dnorm() is applied to calculate the probability of a continuous x.

Details

x is a scalar or vector with values from either a categorical or a continuous variable, the probability is calculated for.

Value

Probability of x.

See Also

Normal

Other Utils: as_ANN_matrix(), degree(), distance(), list_as_numeric(), radian(), random_seed(), re.factor(), sd_pop(), similarity(), var_pop(), vector_as_ANN_matrix(), vector_as_numeric()

Examples

  # Getting the probability distribution of a factor variable y
  probability(levels(y), y)
  # Calculate the probability of every entry within a factor variable y
  probability(y, y)
  # Calculate the probability of certain levels or characters of a factor variable y
  probability(c("Oma", "Opa"), y)

  # Compute the probability of a numeric variable underlying a gaussian probability density function
  # with mean and standard deviation of x
  x <- 1:10
  probability(x)
  # with pregiven mean and standard deviation
  probability(x, mean = 0, sd = 1)

stschn/deepANN documentation built on June 25, 2024, 7:27 a.m.