grade.discreteprobability: Grade Discrete Probability Sets

Description Usage Arguments Details Value Note See Also Examples

View source: R/grade.discreteprobability.R

Description

Checks a students probability distribution, makes sure that (1) It sums to 1 (2) All elements are >= 0

Optionally, it compares the students to a correct one. Order is optionally enforced.

Usage

1
2
3
grade.discreteprobability(correctans, studentans, tolerance=.01,
                          useeval=TRUE, usena=FALSE, useinf=FALSE,
                          quiet=TRUE, ordered=FALSE, checkcorrect=TRUE)

Arguments

correctans

a vector of type numeric or a string

studentans

a vector of type numeric or a string

tolerance

a string or numeric representing the accepted component wise tolerance

useeval

TRUE or FALSE indicates whether or not to use 'eval' on strings

usena

TRUE or FALSE indicating whether or not NA is an accepted value

useinf

TRUE or FALSE indicating whether or not Inf and -Inf are accepted values

quiet

TRUE or FALSE. If TRUE there are more warning messages when checks fail. Can be helpful for debugging.

ordered

TRUE or FALSE. If TRUE studentans order must match correctans order to be considered correct. If FALSE, order does not matter (so both are sorted and then checked)

checkcorrect

TRUE or FALSE. if TRUE studentans needs to match correctans. If FALSE studentans only needs to qualify as a discrete probability distribution.

Details

If checkcorrect=FALSE, grade.discreteprobability does not do any checks on correctans. In this case to be correct, studentans needs to satisfy discrete probability constraints – all elements >= 0 and sums to 1.

If checkcorrect=TRUE discrete probability constraints are enforced on correctans. studentans needs to match correctans in this case. Order is only enforced if ordered=TRUE.

grade.discreteprobability does not use NA. If usena=TRUE grade.discreteprobability sets it to FALSE and issues a warning message.

Value

TRUE or FALSE indicating match success or failure respectively. FALSE is also returned if studentans does not look like a set.

Note

The grade main page contains a discussion of the common parameters correctans, studentans, useeval, usena, useinf, quiet.

See Also

grade grade.set

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# TRUE
grade.discreteprobability(c(1/2,1/2), "[.5, .5]")
# TRUE
grade.discreteprobability(NULL, "[0, .33, .17, .5]", checkcorrect=FALSE) 

# FALSE
grade.discreteprobability(NULL, "[-1, 0, 0, 1, 1]", checkcorrect=FALSE)

# TRUE
grade.discreteprobability(c(0, 1/2, 1/4, 1/4), "[0, 1/2, 1/4, 1/4]")
# FALSE
grade.discreteprobability(c(0, 1/2, 1/4, 1/4), "[0, .25, .25, .5]",
                          ordered=TRUE)

# TRUE
grade.discreteprobability(c(0, 1/2, 1/4, 1/4), "[0, .5, .25, .25]",
                          ordered=TRUE)

grade documentation built on May 2, 2019, 9:15 a.m.