Class: Kot::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/kot/test.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item_bank, est_theta = 0.0, selector = RandomesqueSelector.new, estimator = HillClimbingEstimator.new) ⇒ Test

Returns a new instance of Test.



7
8
9
10
11
12
13
14
15
# File 'lib/kot/test.rb', line 7

def initialize(item_bank, est_theta = 0.0, selector = RandomesqueSelector.new, estimator = HillClimbingEstimator.new)
  @item_bank = item_bank
  @est_theta = est_theta
  @selector = selector
  @estimator = estimator

  @responses = []
  @asked_items = []
end

Instance Attribute Details

#est_thetaObject (readonly)

Returns the value of attribute est_theta.



5
6
7
# File 'lib/kot/test.rb', line 5

def est_theta
  @est_theta
end

Instance Method Details

#next_itemObject

Ask the selector for a new item from the item bank.



29
30
31
32
# File 'lib/kot/test.rb', line 29

def next_item
  possible_items = @item_bank - @asked_items
  @selector.select(@est_theta, possible_items)
end

#respond(response, item) ⇒ Object

Add a response for a given item.



35
36
37
38
39
# File 'lib/kot/test.rb', line 35

def respond(response, item)
  @responses << response
  @asked_items << item
  update_est_theta
end

#seeObject

Get the standard error of estimation for the test so far.



18
19
20
21
# File 'lib/kot/test.rb', line 18

def see
  return Float::INFINITY if @asked_items.empty?
  ItemResponseTheory.see(@est_theta, @asked_items)
end

#update_est_thetaObject

Update the estimated theta for the test so far.



24
25
26
# File 'lib/kot/test.rb', line 24

def update_est_theta
  @est_theta = @estimator.estimate(est_theta: @est_theta, responses: @responses, items: @asked_items, all_items: @item_bank)
end