Forum archive 2000-2006

Jeff Achter - evaluating answers at integers?

Jeff Achter - evaluating answers at integers?

by Arnold Pizer -
Number of replies: 0
inactiveTopicevaluating answers at integers? topic started 4/9/2002; 1:42:12 PM
last post 8/5/2003; 12:42:13 PM
userJeff Achter - evaluating answers at integers?  blueArrow
4/9/2002; 1:42:12 PM (reads: 1983, responses: 5)
I'd like to compare student answers to my own, but only evaluating the functions in question at natural numbers. Is there an easy way to persuade fun_cmp() to do this?

Thanks.

--Jeff

<| Post or View Comments |>


userMichael Gage - Re: evaluating answers at integers?  blueArrow
4/9/2002; 3:14:41 PM (reads: 2315, responses: 0)
There is no easy or automatic way to do this at the moment.

There is a quick and dirty way -- try it and see what modifications work best for you. We'll try to include them in a new version of fun_cmp

First copy the entire subroutine fun_cmp from PGanswermacros.pl to a file myAnswers.pl which you should place in the templates/macro directory of a test course. Include "myAnswers.pl" in the loadMacros() list at the top of your problem. In the myAnswers.pl file change the name fun_cmp to fun_cmp2 and change the calls in your problem from fun_cmp to fun_cmp2 as well.

At this point do some testing and make sure that everything is working as it was when you were using the call to fun_cmp() in PGanswermacros.pl

Now we are set to modify the way evaluation points are chosen. Here is the relevant section of fun_cmp2

 

#create the evaluation points
my $random_for_answers = new PGrandom($main::PG_original_problemSeed);
my $NUMBER_OF_STEPS_IN_RANDOM = 1000; # determines the granularity of the random_for_answers number generator
my (@evaluation_points);
for( my $count = 0; $count < @PARAMS+1+$numPoints; $count++ ) {
my (@vars,$iteration_limit);
for( my $i = 0; $i < @VARS; $i++ ) {
my $iteration_limit = 10;
while ( 0 < --$iteration_limit ) { # make sure that the endpoints of the interval are not included
$vars[$i] = $random_for_answers->random($limits[$i][0], $limits[$i][1], abs($limits[$i][1] - $limits[$i][0])/$NUMBER_OF_STEPS_IN_RANDOM );
last if $vars[$i]!=$limits[$i][0] and $vars[$i]!=$limits[$i][1];
}
warn "Unable to properly choose evaluation points for this function in the interval ( $limits[$i][0] , $limits[$i][1] )"
if $iteration_limit == 0;
};

push(@evaluation_points,@vars);
}
my $evaluation_points = Matrix->new_from_array_ref(@evaluation_points);

One modification would be to replace

abs($limits[$i][1] - $limits[$i][0])/$NUMBER_OF_STEPS_IN_RANDOM
with 1 in order to get only integer values.

Another possibility, which I think we will get to eventually, will be to make it possible to specify subroutine for selecting specific evaluation points which replaces the standard routine.

Hope this helps. Let us know how it goes.

-- Mike

<| Post or View Comments |>


userDavid Vos - Re: evaluating answers at integers?  blueArrow
4/10/2002; 1:31:05 PM (reads: 2291, responses: 0)
I handled a similar situation by cheating this way:

ANS( function_cmp($ans1, "n", 1, 1001));

(assuming the function is defined for n == 1001).

Hope this helps. But it will probably not work in future versions of webwork.

David

<| Post or View Comments |>


userJohn Jones - Re: evaluating answers at integers?  blueArrow
8/4/2003; 3:24:25 PM (reads: 2064, responses: 0)
Hi,

I have a problem which needs this sort of thing. As far as I know, fun_cmp does not have a provide a mechanism for dealing with it yet. My suggestion is to add a new optional argument to look like this:

 

 fun_cmp("5 (-1)^n (1/10)^(n-1)", vars=>['n'], test_points=>[[1,3,4,5,6]])

The idea is that you can hard-code the test points into the problem, and this would override the random selection of points. With a function like the one given in the example, I would definitely want small integers (or everything is too close to 0), and want that some are odd and some are even. I can't think of any problem with the loss of randomness in function testing when it is used occasionally like this.

The test_points option would follow convensions similar to limits, so that test_points=>[[1,3,4,5,6]] and test_points=>[1,3,4,5,6] would be treated the same (if you have only one variable).

Comments or suggestions on this?

John

<| Post or View Comments |>


userMichael Gage - Re: evaluating answers at integers?  blueArrow
8/5/2003; 12:21:06 AM (reads: 2080, responses: 0)
This seems like a good way to handle this to me. As you can tell from previous postings, this feature has been requested several times, so it is well worth implementing.

Conceivably one could ask for some random points in addition to the specified ones, but I'm inclined to think that it would be conceptually simpler to implement the answer evaluator generator as you suggest, and people can generate their own random points by hand if they wish to have some fixed and some random points.

Thanks for working on this.

-- Mike

<| Post or View Comments |>


userJohn Jones - Re: evaluating answers at integers?  blueArrow
8/5/2003; 12:42:13 PM (reads: 2018, responses: 0)
test_points is now incorporated to the CVS version of fun_cmp. You are right that it is more useful than I originally thought since the problem writer can do their own randomization.

John

<| Post or View Comments |>