Description Usage Arguments Details Value Note See Also Examples
View source: R/grade.discreteprobability.R
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.
1 2 3 |
correctans |
a vector of type |
studentans |
a vector of type |
tolerance |
a |
useeval |
|
usena |
|
useinf |
|
quiet |
|
ordered |
|
checkcorrect |
|
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.
TRUE
or FALSE
indicating match success or failure respectively.
FALSE
is also returned if studentans
does not look like a set.
The grade
main page contains a discussion of the
common parameters correctans, studentans, useeval, usena,
useinf, quiet
.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.