function gen_items($space, $covariate) { global $N_ITEMS, $dims, $COVARIATE_NAME; # Create an item bank to store the items. # Setting the property "sizeHint" increases allocation efficiency # It's a bit kludgy, but the php gtk bindings require passing # the name of the object to the objects constructor in order to # set the construction properties. $bank = new OscatsItemBank('OscatsItemBank', array("sizeHint" => $N_ITEMS)); # Create the items for ($i = 0; $i < $N_ITEMS; $i++) { # 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 = new OscatsModelL2p('OscatsModelL2p', array("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::rnd_normal(sqrt(3))); $model->set_param_by_name("Discr.Cont.1", Oscats::rnd_uniform_range(0, 1)); $model->set_param_by_name("Discr.Cont.2", Oscats::rnd_uniform_range(0, 2)); $model->set_param_by_name($COVARIATE_NAME, Oscats::rnd_uniform_range(0.5, 1.5)); # Create an item based on this model # This is equivalent to oscats_item_new(0, model) in C $item = new OscatsItem(0, $model); # Add the item to the item bank $bank->add_item($item); # Since php is garbage collected, we don't have to worry about # reference counting. } return $bank; }
function gen_items($space) { global $N_ITEMS; # Create an item bank to store the items. # Setting the property "sizeHint" increases allocation efficiency # It's a bit kludgy, but the php gtk bindings require passing # the name of the object to the objects constructor in order to # set the construction properties. $bank = new OscatsItemBank('OscatsItemBank', array("sizeHint" => $N_ITEMS)); for ($i = 0; $i < $N_ITEMS; $i++) { # First we create an IRT model container for our item $model = new OscatsModelL1p('OscatsModelL1p', array("space" => $space)); # Then, set the parameters. Here there is only one, the difficulty (b). $model->set_param_by_index(0, Oscats::rnd_normal(1)); # Create an item based on this model # This is equivalent to oscats_item_new(0, model) in C $item = new OscatsItem(0, $model); # Add the item to the item bank $bank->add_item($item); # Since php is garbage collected, we don't have to worry about # reference counting. } return $bank; }