| grade.discreteprobability {grade} | R Documentation |
Grade Discrete Probability Sets
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
grade.discreteprobability(correctans, studentans, tolerance=.01,
useeval=TRUE, usena=FALSE, useinf=FALSE,
quiet=TRUE, ordered=FALSE, checkcorrect=TRUE)
Arguments
correctans |
a vector of type |
studentans |
a vector of type |
tolerance |
a |
useeval |
|
usena |
|
useinf |
|
quiet |
|
ordered |
|
checkcorrect |
|
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
Examples
# 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)