Skip to content

Commit b8046ec

Browse files
author
Frankie Robertson
committed
Add likelihood to Stateful
1 parent 4526bba commit b8046ec

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/Stateful.jl

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Stateful
88
using DocStringExtensions
99

1010
using FittedItemBanks: AbstractItemBank, ResponseType, ItemResponse, resp_vec
11-
using ..Aggregators: TrackedResponses, Aggregators
11+
using ..Aggregators: TrackedResponses, Aggregators, pdf, distribution_estimator
1212
using ..CatConfig: CatLoopConfig, CatRules
1313
using ..Responses: BareResponses, Response, Responses
1414
using ..NextItemRules: compute_criteria, best_item
@@ -45,6 +45,7 @@ $(FUNCTIONNAME)(config::StatefulCat) -> AbstractVector{IndexT}
4545
Return a vector of indices of the sorted from best to worst item according to the CAT.
4646
"""
4747
function ranked_items end
48+
function ranked_items(::StatefulCat) nothing end
4849

4950
"""
5051
```julia
@@ -56,6 +57,7 @@ Returns a vector of criteria values for each item in the item bank.
5657
The criteria can vary, but should attempt to interoperate with ComputerAdaptiveTesting.jl.
5758
"""
5859
function item_criteria end
60+
function item_criteria(::StatefulCat) nothing end
5961

6062
"""
6163
```julia
@@ -124,6 +126,15 @@ but should attempt to interoperate with ComputerAdaptiveTesting.jl.
124126
"""
125127
function get_ability end
126128

129+
"""
130+
```julia
131+
$(FUNCTIONNAME)(config::StatefulCat, ability::AbilityT) -> Float64
132+
```
133+
134+
TODO
135+
"""
136+
function likelihood end
137+
127138
"""
128139
```julia
129140
$(FUNCTIONNAME)(config::StatefulCat)
@@ -199,8 +210,12 @@ function next_item(config::StatefulCatConfig)
199210
end
200211

201212
function ranked_items(config::StatefulCatConfig)
202-
return sortperm(compute_criteria(
203-
config.rules.next_item, config.tracked_responses[]))
213+
criteria = compute_criteria(
214+
config.rules.next_item, config.tracked_responses[])
215+
if criteria === nothing
216+
return nothing
217+
end
218+
return sortperm(criteria)
204219
end
205220

206221
function item_criteria(config::StatefulCatConfig)
@@ -240,6 +255,10 @@ function get_ability(config::StatefulCatConfig)
240255
return (config.rules.ability_estimator(config.tracked_responses[]), nothing)
241256
end
242257

258+
function likelihood(config::StatefulCatConfig, ability)
259+
pdf(distribution_estimator(config.rules.ability_estimator), config.tracked_responses[], ability)
260+
end
261+
243262
function item_bank_size(config::StatefulCatConfig)
244263
return length(config.tracked_responses[].item_bank)
245264
end

0 commit comments

Comments
 (0)