def gen_items(space, covariate) : # Create an item bank to store the items. # Setting the property "sizeHint" increases allocation efficiency bank = gobject.new(oscats.ItemBank, sizeHint=N_ITEMS) # Create the items for i in range(N_ITEMS) : # First we create an IRT model container for our item # We have to specify which dimensions to be used with the "dims" array # (in this case, we use both of the dimensions of the space) model = gobject.new(oscats.ModelL2p, space=space, dims=dims, covariates=covariate) # Then, set the parameters. Here there are 4: # Discrimination on two dimensions, difficulty, and covariate coef. model.set_param_by_name("Diff", oscats.oscats_rnd_normal(sqrt(3))) model.set_param_by_name("Discr.Cont.1", oscats.oscats_rnd_uniform_range(0, 1)) model.set_param_by_name("Discr.Cont.2", oscats.oscats_rnd_uniform_range(0, 2)) model.set_param_by_name(COVARIATE_NAME, oscats.oscats_rnd_uniform_range(0.5, 1.5)) # Create an item based on this model item = gobject.new(oscats.Item) item.set_model(item.get_default_model(), model) # Add the item to the item bank bank.add_item(item) # Since Python is garbage collected, we don't have to worry about # reference counting. return bank
def gen_items(space, covariate): # Create an item bank to store the items. # Setting the property "sizeHint" increases allocation efficiency bank = gobject.new(oscats.ItemBank, sizeHint=N_ITEMS) # Create the items for i in range(N_ITEMS): # First we create an IRT model container for our item # We have to specify which dimensions to be used with the "dims" array # (in this case, we use both of the dimensions of the space) model = gobject.new(oscats.ModelL2p, space=space, dims=dims, covariates=covariate) # Then, set the parameters. Here there are 4: # Discrimination on two dimensions, difficulty, and covariate coef. model.set_param_by_name("Diff", oscats.oscats_rnd_normal(sqrt(3))) model.set_param_by_name("Discr.Cont.1", oscats.oscats_rnd_uniform_range(0, 1)) model.set_param_by_name("Discr.Cont.2", oscats.oscats_rnd_uniform_range(0, 2)) model.set_param_by_name(COVARIATE_NAME, oscats.oscats_rnd_uniform_range(0.5, 1.5)) # Create an item based on this model item = gobject.new(oscats.Item) item.set_model(item.get_default_model(), model) # Add the item to the item bank bank.add_item(item) # Since Python is garbage collected, we don't have to worry about # reference counting. return bank
def gen_items(space): bank = oscats.ItemBank(sizeHint=N_ITEMS) for i in range(N_ITEMS): model = gobject.new(oscats.ModelL3p, space=space) model.set_param_by_name("Diff", oscats.oscats_rnd_uniform_range(-3, 3)) model.set_param_by_name("Discr.Cont.1", oscats.oscats_rnd_uniform_range(0.8, 2.0)) model.set_param_by_name("Guess", oscats.oscats_rnd_uniform_range(0.1, 0.3)) item = oscats.Item(0, model) bank.add_item(item) return bank