# 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; } ## main() $test_names = array("A-opt", "D-opt", "KL"); $grid = array(-1, 0, 1); # Create the latent space for the test: 2 continuous dimensions $space = new OscatsSpace('OscatsSpace', array("numCont" => 2)); # Fetch the first and second continuous dimensions via the default names $dims = array($space->get_dim_by_name("Cont.1"), $space->get_dim_by_name("Cont.2")); # Create the covariate $covariate = new OscatsCovariates(); $covariate->set_by_name($COVARIATE_NAME, 0); # "covariate" variable now includes one covariate called "MyCovariate" # It's current value is 0. print "Creating items.\n"; $bank = gen_items($space, $covariate); print "Creating tests.\n"; # Create new tests with the given properties # In this case, we know what the length of the test will be (20), # so, we set length_hint for allocation efficiency. # Any good/reasonable guess will do---the size will be adjusted # automatically as necessary. $tests = array(); $err_sums = array();
$theta = new OscatsPoint('OscatsPoint', array("space" => $space)); # Sample the ability from N(0,1) distribution $theta->set_cont($dim, Oscats::rnd_normal(1)); # Create a new examinee $e = new OscatsExaminee(); # Set the examinee's true (simulated) ability $e->set_sim_theta($theta); $ret[] = $e; } return $ret; } ## main() $test_names = array("random", "matched", "match.5", "match.10"); # Create the latent space for the test: continuous unidimensional $space = new OscatsSpace('OscatsSpace', array("numCont" => 1)); $dim = $space->get_dim_by_name("Cont.1"); print "Creating examinees.\n"; $examinees = gen_examinees($space); print "Creating items.\n"; $bank = gen_items($space); print "Creating tests.\n"; # Create new tests with the given properties # In this case, we know what the length of the test will be (30), # so, we set length_hint for allocation efficiency. # Any good/reasonable guess will do---the size will be adjusted # automatically as necessary. $tests = array(); foreach ($test_names as $name) { $tests[] = new OscatsTest('OscatsTest', array("id" => $name, "itembank" => $bank, "length_hint" => $LEN)); } # Register the CAT algorithms for each test