Skip to content

Commit 47ff9af

Browse files
authored
add custom parameters max_iter and tolerance (#5)
1 parent 22b0d94 commit 47ff9af

6 files changed

Lines changed: 12 additions & 12 deletions

File tree

lib/irt_ruby/rasch_model.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
module IrtRuby
66
# A class representing the Rasch model for Item Response Theory.
77
class RaschModel
8-
def initialize(data)
8+
def initialize(data, max_iter: 1000, tolerance: 1e-6)
99
@data = data
1010
@abilities = Array.new(data.row_count) { rand }
1111
@difficulties = Array.new(data.column_count) { rand }
12-
@max_iter = 1000
13-
@tolerance = 1e-6
12+
@max_iter = max_iter
13+
@tolerance = tolerance
1414
end
1515

1616
def sigmoid(x)

lib/irt_ruby/three_parameter_model.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
module IrtRuby
66
# A class representing the Three-Parameter model for Item Response Theory.
77
class ThreeParameterModel
8-
def initialize(data)
8+
def initialize(data, max_iter: 1000, tolerance: 1e-6)
99
@data = data
1010
@abilities = Array.new(data.row_count) { rand }
1111
@difficulties = Array.new(data.column_count) { rand }
1212
@discriminations = Array.new(data.column_count) { rand }
1313
@guessings = Array.new(data.column_count) { rand * 0.3 }
14-
@max_iter = 1000
15-
@tolerance = 1e-6
14+
@max_iter = max_iter
15+
@tolerance = tolerance
1616
end
1717

1818
def sigmoid(x)

lib/irt_ruby/two_parameter_model.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
module IrtRuby
66
# A class representing the Two-Parameter model for Item Response Theory.
77
class TwoParameterModel
8-
def initialize(data)
8+
def initialize(data, max_iter: 1000, tolerance: 1e-6)
99
@data = data
1010
@abilities = Array.new(data.row_count) { rand }
1111
@difficulties = Array.new(data.column_count) { rand }
1212
@discriminations = Array.new(data.column_count) { rand }
13-
@max_iter = 1000
14-
@tolerance = 1e-6
13+
@max_iter = max_iter
14+
@tolerance = tolerance
1515
end
1616

1717
def sigmoid(x)

spec/irt_ruby/rasch_model_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
RSpec.describe IrtRuby::RaschModel do
66
let(:data) { Matrix[[1, 0, 1], [0, 1, 0], [1, 1, 1]] }
7-
let(:irt_model) { IrtRuby::RaschModel.new(data) }
7+
let(:irt_model) { IrtRuby::RaschModel.new(data, max_iter: 2000) }
88

99
describe "#sigmoid" do
1010
it "calculates the sigmoid of a value" do

spec/irt_ruby/three_parameter_model_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
RSpec.describe IrtRuby::ThreeParameterModel do
66
let(:data) { Matrix[[1, 0, 1], [0, 1, 0], [1, 1, 1]] }
7-
let(:model) { IrtRuby::ThreeParameterModel.new(data) }
7+
let(:model) { IrtRuby::ThreeParameterModel.new(data, max_iter: 1500) }
88

99
describe "#initialize" do
1010
it "initializes with data" do

spec/irt_ruby/two_parameter_model_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
RSpec.describe IrtRuby::TwoParameterModel do
66
let(:data) { Matrix[[1, 0, 1], [0, 1, 0], [1, 1, 1]] }
7-
let(:model) { IrtRuby::TwoParameterModel.new(data) }
7+
let(:model) { IrtRuby::TwoParameterModel.new(data, max_iter: 3000) }
88

99
describe "#initialize" do
1010
it "initializes with data" do

0 commit comments

Comments
 (0)