draw: Draws any distribution

View source: R/draw.R

drawR Documentation

Draws any distribution

Description

By providing X and their probability, you can draw either CDF or PMF

Usage

draw(
  X,
  p,
  cumulative = F,
  sort.prob = F,
  round = 3,
  show.label = TRUE,
  nudge = 0
)

Arguments

X

Mishtane Mikri. Can be a vector of values.

cumulative

a logical. If TRUE: draws a CDF. default is set to FALSE.

sort.prob

a logical. Concerns the data frame returned, if TRUE: sort by probability (in decreasing order), Otherwise same order as input of X. default is set to FALSE.

round

How many decimals to show. Default is set to 3.

show.label

A logical. Default (TRUE) prints probability labels on the plot.

nudge

When show.label is TRUE, you can adjust the location of the labels by inputing a 2 length vector to adjust the label position (a single values works too). Usualy no adjustment is needed.

P

Probability. Should be the same length as X (also vectorized).

Value

graph (Print only).

Tohelet and Shonut (Print only).

data.frame of X and their probs (use sort.prob to change order method).

Note

Probs can add up to more than 1, It will work, but not advised and a warning message will appear. Negative probs will be automatically corrected to absolute value.

See Also

For a fully detailed explanation about the differences between distributions please visit https://www.researchgate.net/post/What-is-the-difference-between-probability-distribution-function-and-probability-density-function

Examples

x <- c(1:5)
p <- c(0.1,0.2,0.25,0.25,0.2)
draw(x,p)
draw(x,p,cumulative=TRUE, sort.prob=TRUE)
dice <- 1:6
draw(dice,-1/6)
## Even when using negative probability, it will work.

bgupsych/bgupsych documentation built on Nov. 1, 2023, 9:41 a.m.