Package 'vistributions'

Title: Visualize Probability Distributions
Description: Visualize and compute percentiles/probabilities of normal, t, f, chi square and binomial distributions.
Authors: Aravind Hebbali [aut, cre]
Maintainer: Aravind Hebbali <[email protected]>
License: MIT + file LICENSE
Version: 0.2.0
Built: 2024-12-08 07:20:13 UTC
Source: CRAN

Help Index


Visualize binomial distribution

Description

Visualize how changes in number of trials and the probability of success affect the shape of the binomial distribution. Compute & visualize probability from a given quantile and quantiles out of given probability.

Usage

vdist_binom_plot(n = 10, p = 0.3, print_plot = TRUE)

vdist_binom_prob(
  n = 10,
  p = 0.3,
  s = 4,
  type = c("lower", "upper", "exact", "interval"),
  print_plot = TRUE
)

vdist_binom_perc(
  n = 10,
  p = 0.5,
  tp = 0.05,
  type = c("lower", "upper"),
  print_plot = TRUE
)

Arguments

n

Number of trials.

p

Aggregate probability.

print_plot

logical; if TRUE, prints the plot else returns a plot object.

s

Number of success.

type

Lower/upper/exact/interval.

tp

Probability of success in a trial.

See Also

Binomial

Examples

# visualize binomial distribution
vdist_binom_plot(10, 0.3)

# visualize probability from a given quantile
vdist_binom_prob(10, 0.3, 4, type = 'exact')
vdist_binom_prob(10, 0.3, 4, type = 'lower')
vdist_binom_prob(10, 0.3, 4, type = 'upper')
vdist_binom_prob(10, 0.3, c(4, 6), type = 'interval')


# visualize quantiles out of given probability
vdist_binom_perc(10, 0.5, 0.05)
vdist_binom_perc(10, 0.5, 0.05, "upper")

Visualize chi square distribution

Description

Visualize how changes in degrees of freedom affect the shape of the chi square distribution. Compute & visualize quantiles out of given probability and probability from a given quantile.

Usage

vdist_chisquare_plot(
  df = 3,
  normal = FALSE,
  xaxis_range = 25,
  print_plot = TRUE
)

vdist_chisquare_perc(
  probs = 0.95,
  df = 3,
  type = c("lower", "upper"),
  print_plot = TRUE
)

vdist_chisquare_prob(
  perc = 13,
  df = 11,
  type = c("lower", "upper"),
  print_plot = TRUE
)

Arguments

df

Degrees of freedom.

normal

If TRUE, normal curve with same mean and sd as the chi square distribution is drawn.

xaxis_range

The upper range of the X axis.

print_plot

logical; if TRUE, prints the plot else returns a plot object.

probs

Probability value.

type

Lower tail or upper tail.

perc

Quantile value.

See Also

Chisquare

Examples

# visualize chi square distribution
vdist_chisquare_plot()
vdist_chisquare_plot(df = 5)
vdist_chisquare_plot(df = 5, normal = TRUE)

# visualize quantiles out of given probability
vdist_chisquare_perc(0.165, 8, 'lower')
vdist_chisquare_perc(0.22, 13, 'upper')

# visualize probability from a given quantile.
vdist_chisquare_prob(13.58, 11, 'lower')
vdist_chisquare_prob(15.72, 13, 'upper')

Visualize f distribution

Description

Visualize how changes in degrees of freedom affect the shape of the F distribution. Compute & visualize quantiles out of given probability and probability from a given quantile.

Usage

vdist_f_plot(num_df = 4, den_df = 30, normal = FALSE, print_plot = TRUE)

vdist_f_perc(
  probs = 0.95,
  num_df = 3,
  den_df = 30,
  type = c("lower", "upper"),
  print_plot = TRUE
)

vdist_f_prob(
  perc = 2.35,
  num_df = 5,
  den_df = 32,
  type = c("lower", "upper"),
  print_plot = TRUE
)

Arguments

num_df

Degrees of freedom associated with the numerator of f statistic.

den_df

Degrees of freedom associated with the denominator of f statistic.

normal

If TRUE, normal curve with same mean and sd as the F distribution is drawn.

print_plot

logical; if TRUE, prints the plot else returns a plot object.

probs

Probability value.

type

Lower tail or upper tail.

perc

Quantile value.

See Also

FDist

Examples

# visualize F distribution
vdist_f_plot()
vdist_f_plot(6, 10, normal = TRUE)

# visualize probability from a given quantile
vdist_f_perc(0.95, 3, 30, 'lower')
vdist_f_perc(0.125, 9, 35, 'upper')

# visualize quantiles out of given probability
vdist_f_prob(2.35, 5, 32)
vdist_f_prob(1.5222, 9, 35, type = "upper")

Launch shiny app

Description

Launches shiny app for visualizing distributions.

Usage

vdist_launch_app()

Examples

## Not run: 
vdist_launch_app ()

## End(Not run)

Visualize normal distribution

Description

Visualize how changes in mean and standard deviation affect the shape of the normal distribution. Compute & visualize quantiles out of given probability and probability from a given quantile.

Usage

vdist_normal_plot(mean = 0, sd = 1, print_plot = TRUE)

vdist_normal_perc(
  probs = 0.95,
  mean = 0,
  sd = 1,
  type = c("lower", "upper", "both"),
  print_plot = TRUE
)

vdist_normal_prob(
  perc = 3,
  mean = 0,
  sd = 1,
  type = c("lower", "upper", "both"),
  print_plot = TRUE
)

Arguments

mean

Mean of the normal distribution.

sd

Standard deviation of the normal distribution.

print_plot

logical; if TRUE, prints the plot else returns a plot object.

probs

Probability value.

type

Lower tail, upper tail or both.

perc

Quantile value.

See Also

Normal

Examples

# visualize normal distribution
vdist_normal_plot()
vdist_normal_plot(mean = 2, sd = 0.6)

# visualize quantiles out of given probability
vdist_normal_perc(0.95, mean = 2, sd = 1.36)
vdist_normal_perc(0.3, mean = 2, sd = 1.36, type = 'upper')
vdist_normal_perc(0.95, mean = 2, sd = 1.36, type = 'both')

# visualize probability from a given quantile
vdist_normal_prob(3.78, mean = 2, sd = 1.36)
vdist_normal_prob(3.43, mean = 2, sd = 1.36, type = 'upper')
vdist_normal_prob(c(-1.74, 1.83), type = 'both')

Visualize t distribution

Description

Visualize how degrees of freedom affect the shape of t distribution, visualize quantiles out of given probability and probability from a given quantile.

Usage

vdist_t_plot(df = 3, print_plot = TRUE)

vdist_t_perc(
  probs = 0.95,
  df = 4,
  type = c("lower", "upper", "both"),
  print_plot = TRUE
)

vdist_t_prob(
  perc = 1.6,
  df = 7,
  type = c("lower", "upper", "interval", "both"),
  print_plot = TRUE
)

Arguments

df

Degrees of freedom.

print_plot

logical; if TRUE, prints the plot else returns a plot object.

probs

Probability value.

type

Lower tail, upper tail, interval or both.

perc

Quantile value.

See Also

TDist

Examples

# visualize t distribution
vdist_t_plot()
vdist_t_plot(6)
vdist_t_plot(df = 8)

# visualize quantiles out of given probability
vdist_t_perc(probs = 0.95, df = 4, type = 'lower')
vdist_t_perc(probs = 0.35, df = 4, type = 'upper')
vdist_t_perc(probs = 0.69, df = 7, type = 'both')

# visualize probability from a given quantile
vdist_t_prob(2.045, 7, 'lower')
vdist_t_prob(0.945, 7, 'upper')
vdist_t_prob(1.445, 7, 'interval')
vdist_t_prob(1.6, 7, 'both')