kot 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/kot/hill_climbing_estimator.rb +36 -22
- data/lib/kot/item_response_theory.rb +1 -2
- data/lib/kot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3d7be21381f93bf3481b87a3167afeb00bc85101113fb55031d25d169434d56
|
4
|
+
data.tar.gz: 57e6c62c8bf39ff09f63db2c9c70a4f3c3727ade7e216ea1cc26d7a8a42dd67f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfade4c0dda38f2ad2d8182abacecb4686088c6323a6a0c044507ba921aebe8fb552b3b92eb8c7a0f24a0d62d21762ce623de852d30a38b069c0cd0b42a9354e
|
7
|
+
data.tar.gz: a59fbf2efccc4843e456c8a5093e263030411250d100f42163425f4b22a6b3ce778acf94a69c1d67e066f95c8dd5b0e5ec75a2db4eadd7d3eae0e32c65d2cfa8
|
@@ -12,46 +12,60 @@ module Kot
|
|
12
12
|
last_response ? est_theta + ((max_b - est_theta) / 2.0) : est_theta - ((est_theta - min_b) / 2.0)
|
13
13
|
end
|
14
14
|
|
15
|
-
def estimate(responses:[], items:[], all_items:[], est_theta:0.0)
|
16
|
-
|
17
|
-
|
18
|
-
if responses.uniq.count == 1
|
19
|
-
raise ArgumentError.new("Responses are all #{responses.first} but missing all_items argument") if all_items.empty?
|
20
|
-
return dodd(est_theta:est_theta, items:all_items, last_response:responses.last)
|
21
|
-
end
|
22
|
-
|
23
|
-
lower_bound = items.map(&:b).min
|
24
|
-
upper_bound = items.map(&:b).max
|
25
|
-
|
26
|
-
return lower_bound if upper_bound == lower_bound
|
27
|
-
|
28
|
-
best_theta = - Float::INFINITY
|
29
|
-
max_ll = - Float::INFINITY
|
30
|
-
|
31
|
-
10.times do
|
32
15
|
|
16
|
+
def estimate_iteration(best_theta, max_ll, lower_bound, upper_bound, responses, items)
|
33
17
|
step_size = (upper_bound - lower_bound) / 10
|
34
|
-
|
18
|
+
|
19
|
+
case step_size <=> 0
|
20
|
+
when 1
|
21
|
+
intervals = (lower_bound..upper_bound).step(step_size).each
|
22
|
+
when -1
|
23
|
+
intervals = (upper_bound..lower_bound).step(step_size.abs).reverse_each
|
24
|
+
when 0
|
25
|
+
intervals = []
|
26
|
+
end
|
35
27
|
|
36
28
|
intervals.each do |ii|
|
37
29
|
|
38
30
|
ll = ItemResponseTheory.log_likelihood(ii, responses, items)
|
39
31
|
|
40
|
-
|
41
32
|
if ll > max_ll
|
42
33
|
max_ll = ll
|
43
34
|
|
44
35
|
#TODO - precision-based early exit
|
45
36
|
best_theta = ii
|
46
37
|
else
|
47
|
-
lower_bound = best_theta - step_size
|
48
|
-
upper_bound =
|
38
|
+
lower_bound = best_theta - step_size.abs
|
39
|
+
upper_bound = ii
|
49
40
|
break
|
50
41
|
end
|
51
42
|
|
52
43
|
end
|
53
44
|
|
54
|
-
|
45
|
+
return best_theta, max_ll, lower_bound, upper_bound
|
46
|
+
end
|
47
|
+
|
48
|
+
def estimate(responses:[], items:[], all_items:[], est_theta:0.0)
|
49
|
+
if responses.uniq.count == 1
|
50
|
+
raise ArgumentError.new("Responses are all #{responses.first} but missing all_items argument") if all_items.empty?
|
51
|
+
return dodd(est_theta:est_theta, items:all_items, last_response:responses.last)
|
52
|
+
end
|
53
|
+
|
54
|
+
lower_bound = items.map(&:b).min
|
55
|
+
upper_bound = items.map(&:b).max
|
56
|
+
|
57
|
+
return lower_bound if upper_bound == lower_bound
|
58
|
+
|
59
|
+
best_theta = - Float::INFINITY
|
60
|
+
max_ll = - Float::INFINITY
|
61
|
+
|
62
|
+
old_best_theta = best_theta
|
63
|
+
|
64
|
+
10.times do
|
65
|
+
best_theta, max_ll, lower_bound, upper_bound =
|
66
|
+
estimate_iteration(best_theta, max_ll, lower_bound, upper_bound, responses, items)
|
67
|
+
|
68
|
+
break if lower_bound == upper_bound
|
55
69
|
end
|
56
70
|
|
57
71
|
return best_theta
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Kot
|
2
2
|
|
3
|
-
|
4
3
|
# Requires a, b, c, d
|
5
4
|
module ItemResponseTheory
|
6
5
|
|
@@ -37,7 +36,7 @@ module Kot
|
|
37
36
|
|
38
37
|
# Item characteristic curve
|
39
38
|
def icc(theta)
|
40
|
-
c + ((d - c) / (1 + icc_component(theta)))
|
39
|
+
c + ((d - c) / (1.0 + icc_component(theta)))
|
41
40
|
end
|
42
41
|
|
43
42
|
# Information value of an item
|
data/lib/kot/version.rb
CHANGED