Homework 4 Grading Guidelines

5 views
Skip to first unread message

Simon Spicer

unread,
Apr 27, 2011, 9:00:20 PM4/27/11
to 480...@googlegroups.com
Hi Everyone

This week's grading assignments are out. Please return them by replying to the grading email by Friday 14:30. If you submitted a homework but didn't receive one to grade, please let me know. You may give half points if you so desire.

There is a lot of free reign in this homework. You should test each of the three functions on the following arrays:

sage: m = matrix(RDF,[[1,2],[2,3],[-1,3],[0,4]]); m
[ 1.0  2.0]
[ 2.0  3.0]
[-1.0  3.0]
[ 0.0  4.0]
sage: m.echelon_form()
[1.0 0.0]
[0.0 1.0]
[0.0 0.0]
[0.0 0.0]

sage: m = matrix(RDF,[[1,2,3],[4,5,6],[7,8,9]]); m
[1.0 2.0 3.0]
[4.0 5.0 6.0]
[7.0 8.0 9.0]
sage: m.echelon_form()
[ 1.0  0.0 -1.0]
[ 0.0  1.0  2.0]
[ 0.0  0.0  0.0]

sage: m = matrix(RDF,[[3,-1,-3,1],[0,0,3,1],[1,-3,0,-3]]); m
[ 3.0 -1.0 -3.0  1.0]
[ 0.0  0.0  3.0  1.0]
[ 1.0 -3.0  0.0 -3.0]
sage: m.echelon_form()
[           1.0            0.0            0.0          1.125]
[           0.0            1.0            0.0          1.375]
[           0.0            0.0            1.0 0.333333333333]

sage: m = matrix(RDF,[[1,4,9,16,25],[2,4,6,8,10],[2,3,5,7,11]]); m
[ 1.0  4.0  9.0 16.0 25.0]
[ 2.0  4.0  6.0  8.0 10.0]
[ 2.0  3.0  5.0  7.0 11.0]
sage: m.echelon_form()
[ 1.0  0.0  0.0 -0.5  1.5]
[ 0.0  1.0  0.0 -1.5 -6.5]
[ 0.0  0.0  1.0  2.5  5.5]

If you copy the above text directly into Sage, you can use 'numpy.array(m)' to coerce the matrices directly into Numpy arrays with float64 entries.

You don't have to test the gradee's code on numpy arrays with int dtypes; it suffices to stick to those arrays with float dtypes.

Finally, when it comes to giving partial grade, I've given guidelines below, but don't be afraid to use your own judgement. Just remember to justify your grading in the write-up. Comments and constructive criticism are especially important in this week's grading.

Regards
Simon Spicer


Total: X/20 points.

Question 1: X/10 points

Your comments here.

Don't worry about roundoff/approximation errors, numerical stability issues etc. If the gradee's code produces the same or almost the same echelon as Sage's echelon_form() method for the above arrays, you can give full grade. Also, don't worry trying to construct pathologically difficult examples to test; the focus of this homework set is not on algorithmic/numerical wizardry, but rather on optimization using Cython.

10 points: The gradee's code successfully computes the echelon form of the arrays listed above. It is okay if the algorithm fails for corner cases, exceptionally large arrays, int arrays etc. It also doesn't matter if the code isn't neat or commented (although hopefully it is).
7-9 points: The code works but produces the wrong output, or contains easily fixable errors.
4-6 points: The function works on some of the inputs, but is seriously flawed, or the code can be made to work with relatively few adjustments.
1-3 points: The code does not work; however, a moderate to serious attempt has been made at the problem.
0 points: The question has not been attempted.

Question 2: X/4 points total

Your comments here.

For this question, the minimum amount of work should have been done to make the code compile in Cython. If the code compiles and it looks identical to the previous question except for an %Cython at the top (and the gradee's Python function works perfectly), you may give full grade.

This question also calls for comparing timings of various array sizes and dtypes. It's okay if this has been rolled into the analysis of question 3, but subtract a point if it hasn't been mentioned at all.

4 points: The gradee's code successfully compiles, and produces exactly correct output for the array examples given above.
3 points: The code compiles but produces incorrect output on some of the test arrays, or it doesn't compile but can be made to do so with minimal effort.
2 points: The code compiles but produces completely bogus output, or the code doesn't compile, but could conceivably be made to work with a moderate amount of effort.
1 point: The code does not compile and is not likely to without considerable effort; however, an attempt has been made at the problem.
0 points: The question has not been attempted.

Question 3: X/6 points total

Your comments here.

To get full grade, the gradee must have done two things:
  • Invoked some Cython-specific structure to speed up the function. This could include, for example, using a cdef or cpdef function, or using Cython objects. A good rule of thumb is that if the %Cython is removed from the top of the cell, the code no longer executes as pure Python. 
  • Explicitly benchmarked their new code versus their old code, as required by the question, and written some sort of an analysis thereon.
These parts are worth 3 points each.

Cythonizing:
3 points: The gradee has incorporated some nontrivial Cythonic structure in their code; it compiles, and produces the same output as question 2
2 points: As above, but the code no longer compiles (but can be made to do so relatively easily), or the output has been altered
1 point: An attempt has been made to modify the code of question 2, but the code does not compile or produces completely bogus output
0 points: This part of the question has not been attempted.

Benchmarking:
3 points: The code has been explicitly timed on some inputs and compared to the running times of the code from the previous two questions. Some comment has been made about performance.
2 points: Some timings have been made, but the results are generally terse/uninformative, or no comment on the timings has been made.
1 point: Timings have been described qualitatively but not listed explicitly.
0 points: This part of the question has not been attempted.

It doesn't matter if the gradee's new code is not, in fact, faster than their code from question 1 or 2 (although this would be nice), so long as it has been sufficienty Cythonized and benchmarked (Numpy has been so heavily optimized that it will be difficult to get huge speedups in any case).

...

Simon Spicer

unread,
May 11, 2011, 6:42:13 PM5/11/11
to 480...@googlegroups.com
Hi Everyone

This week's grading assignments are out. Please return them by replying to the grading email by Friday 14:30. If you submitted a homework but didn't receive one to grade, please let me know. You may give half points if you so desire.

This week should be fairly straight forward. For each question, award full grade if the plot produced looks sufficiently close to that on the problem set. The details of what is meant by "sufficiently close" are given below. This week I have attached a solution worksheet for this homework, with the code that generated each of the plots. Please check that your gradee has actually written code to generate plots, and not just displayed static pictures lifted from elsewhere.

Finally, when it comes to giving partial grade, I've given guidelines below, but don't be afraid to use your own judgement. Just remember to justify your grading in the write-up. Comments and constructive criticism are always appreciated.

Regards
Simon Spicer


Total: X/20 points.

Question 1: X/3 points

Your comments here.

Each of the following features is worth 1 point:
  • The graph plots y = sin(x)
  • The plot colour is blue
  • The x-range is between -3*pi and 3*pi.


Question 2: X/4 points

Your comments here.

If the gradee gets any of the following bullet points partially correct you may give a half point. Don't mark the gradee down if the placement of the smiley's eyes and mouth aren't exactly as in the problem set, so long they have produced blue eyes and horizontal line on a yellow circle.

Each of the following features is worth 1 point:
  • A yellow circle in the background
  • Two smaller blue eyes on top
  • A horizontal blue thin rectangle/thick line below the eyes
  • The plot renders the circle as an actual circle (for example, if aspect_ratio=1 has been explicitly), and no axes are visible (axes=False)


Question 3: X/3 points

Your comments here.

The matplotlib code that you were directed to for this question generates a random collection of shapes, so please do not deduct points if the plot produced doesn't have the exact same shapes in the same place as the picture in the problem set. The copied code only needs two simple changes to ensure it renders in the Notebook, detailed below:

Each of the following features is worth 1 point:
  • The correct matplotlib code has been copied and pasted from http://matplotlib.sourceforge.net/gallery.html. Also c.f. the solution worksheet to see this code in action.
  • There is a %python at the top of the cell
  • "pylab.show()" has been changed to "pylab.savefig('a.png')" or something similar to make the plot show

If for some reason the gradee has attempted to write their own code, or modified the matplotlib code more heavily than the above two points, use your discretion to grade the result by how close it looks to the picture in the problem set. Just don't forget to justify your grading in your writeup.


Question 4: X/4 points

Your comments here.

In this and the next question, it's okay if the viewpoint isn't the same as in the problem set picture. However, for this question the default plot viewpoint is the one you want, so this shouldn't be an issue here.

Each of the following features is worth 1 point:
  • The graph plots z = sin(x - y)*y* cos(x).
  • The plot colour is blue
  • The x-range and y-range are both from -3 to 3
  • The viewer has been changed to tachyon



Question 5: X/6 points

Your comments here.

As mentioned above, it's okay if the viewpoint isn't the same as in the problem set picture. 
Also, it's okay if the gradee hasn't achieved the two-tone effect visible in the problem set plot.

The following features are worth a variable number of points. Again, you may give partial credit or half points for partially correct bullet points.
  • (2 points): The graph plots a Möbius strip. NOTE:there are multiple ways to do this in Sage. One way is to import the Moebius class and use plot(), another is to explicitly use parametricplot3d() on a set of equations that defines a Möbius strip (this is the method used in the solution worksheet). There are possibly other ways too. They are all fine, so long as a Möbius strip ends up in the plot figure.
  • (1 point): The plot colour is green
  • (1 point): The viewer is JMol (not tachyon or canvas3d), and there is no frame
  • (2 points): The Moëbius strip has been given a black border, including the two short straight connecting lines

...

HW 6 Solutions.sws

Simon Spicer

unread,
May 11, 2011, 7:00:03 PM5/11/11
to 480...@googlegroups.com
I mean Homework 6 grading guidelines.

Regards
Simon Spicer
<HW 6 Solutions.sws>

Simon Spicer

unread,
May 18, 2011, 6:01:40 PM5/18/11
to 480...@googlegroups.com
Hi Everyone

This week's grading assignments are out. Please return them by replying to the grading email by Friday 14:30. If you submitted a homework but didn't receive one to grade, please let me know. You may give half points if you so desire.

This is a short homework, so it shouldn't take long to grade. There's no single right way to tackle each of these problems, although in each case the gradee should supply code that outputs the desired answer.

NB: In a previous version of HW 7 this Question 1 involved checking the integers from 2000 to 2060, not 2500. Do not mark the gradee down if they have used 2060 instead of 2500; just grade the question using 2060 as the upper bound.

Regards
Simon Spicer


Total: X/20 points.

Question 1: X/10 points

Your comments here.

Part (a):  X/5 points

The gradee should supply code that computes the factorizations of the integers from 2000 to 2500, most likely using the factor() function. This can be done in a two-line for loop, although there are plenty ways to get the answer out. It's perfectly fine if the gradee has coded up their own factoring function.

Award full grade if the code successfully produces the factorizations of n from n=2000 to 2500 (check the boundary cases; dock half a point if the loop starts at 2001 or ends at 2499 or both).
3-4 points: the output is supplied but no code, or the code is mildly broken.
1-2 points: An incorrect output or no output whatsoever is produced, but the question has been attempted in some manner.
0 points: The question has not been attempted.

Part (b): X/5 points

The correct answer is 2310 = 2*3*5*6*11, i.e. 5 distinct factors. If the gradee used 2060 as their upper limit, then the maximum number of distinct factors is four, and there are five such numbers (2002, 2010, 2030, 2040, 2046). In either case, the gradee should list code using some checking procedure to produce this output.

Award full grade if the code successfully checks the factorizations of all n from 2000 to 2500 (or 2060).
3-4 points: An incorrect answer is produced through some minor error in the code, or the correct output is supplied but without code to back it up.
1-2 points: The code is completely broken, but the question has been attempted in some manner.
0 points: The question has not been attempted.

Question 2: X/10 points total

Your comments here.

Part (a): X/10 points

There are plenty ways to tackle this one. At the end of the day, though, the gradee should have code that loops through the integers from 3 to 1000 and outputs True if "abs(prime_pi(x)-Li(x)) > sqrt(x)*log(x)", and False otherwise. Another way would be to define a function equal to sqrt(x)*log(x) - abs(prime_pi(x)-Li(x)) and check that it's positive between 3 and 1000.

10 points: The gradee's code does as described above. Again, deduct half a point if the edge values are not checked.
7-9 points: The code is essentially correct but contains some minor errors.
4-6 points: Output is supplied but no code, or the code is moderately broken.
1-3 points: The code is completely broken, but the question has been attempted in some manner.
0 points: The question has not been attempted

Part (b): 0/0 Points

Note that this part of Question 2 is optional, so it's okay if the gradee hasn't done it. There are many ways to reason why the Riemann Hypothesis holding for n=3 to 1000 implies that it also holds for all the intervening real numbers. One line of reasoning goes something like this: First , note that we can just manually check that the inequality holds for x up until about 10. Beyond that L(x) is always bigger than pi(x) (at least for the range of values that we're checking), so abs(pi(x)-Li(x)) = Li(x)-pi(x). Next, note that Li(x) is increasing, so for any x Li(x) <= Li(ceil(x)), where ceil(x) is x rounded up to the nearest integer. Also note that pi(x) only increases at the integers, so pi(x) = pi(floor(x)), where floor(x) is x rounded down to the nearest integer.

Putting this all together we see that if x sits between some integer n and n+1, then Li(x)-pi(x) <= Li(n+1) - pi(n). Hence it suffices to just check that Li(n+1) - pi(n) <= sqrt(n)*log(n) on the integers from about 8 up to 1000. This you can easily do by updating your code from part (a).

Again, there are other ways to deduce this result. If the gradee has put forth some particularly crafty and impressive logic, perhaps mention so in the comments.

...

djri...@uw.edu

unread,
May 18, 2011, 7:42:30 PM5/18/11
to 480...@googlegroups.com
Hi Simon,

A small correction to your email, 2310 =/ 2*3*5*6*11. Your 6 should be a 7.

Daniel

From: 480...@googlegroups.com [480...@googlegroups.com] on behalf of Simon Spicer [eigenp...@gmail.com]
Sent: Wednesday, May 18, 2011 3:01 PM
To: 480...@googlegroups.com
Subject: Fwd: Homework 7 Grading Guidelines

Simon Spicer

unread,
May 18, 2011, 7:46:47 PM5/18/11
to 480...@googlegroups.com
Hi Everyone

So it turns out 6 is not a prime number. In Question I wrote the integer between 2000 and 2500 with the most unique prime factors is 2310 = 2*3*5*6*11. It should be2310 = 2*3*5*7*11.

Regards
Simon Spicer

Priya Rao Chagaleti

unread,
May 19, 2011, 2:58:59 AM5/19/11
to 480...@googlegroups.com
Dear Simon,

One more correction: Shouldn't "True if abs(prime_pi(x)-Li(x)) > sqrt(x)*log(x)" be changed to "True if abs(prime_pi(x)-Li(x)) <= sqrt(x)*log(x)"?

-Priya

Simon Spicer

unread,
May 19, 2011, 9:59:04 AM5/19/11
to 480...@googlegroups.com
Hi Priya

Depends which one you (or your grader) catches and prints out. So long as you have a way to differentiate between whether the inequality holds or not, it's fine. But yes, I probably meant "False if abs(prime_pi(x)-Li(x)) > sqrt(x)*log(x)" and True otherwise.

Regards
Simon Spicer

Simon Spicer

unread,
May 25, 2011, 6:15:28 PM5/25/11
to 480...@googlegroups.com
Hi Everyone

This week's grading assignments (the last ever) are out. Please return them by replying to the grading email by Friday 14:30. If you submitted a homework but didn't receive one to grade, please let me know.
Regards
Simon Spicer


Total: X/20 points.

Question 1: X/11 points

Your comments here.

The first 100 integers have median 101/2 = 50.5 and mean 101/2 = 50.5. The biased standard deviation is 1/2*sqrt(3333) = 28.86607... and the unbiased (sample) standard deviation is 5*sqrt(101/3) = 29.01149... Either of the last two answers is fine in the gradee's code.

Note that there are a few different ways to define the median when it comes to sets of even cardinality. The definition Sage uses is the value halfway between the middle two values, but other sources list the median as the larger or smaller of the middle two values. In any case the gradee should just use whichever is the default option of the relevant median function. When it comes to writing their own code in part (f), any of the three definitions is fine.

For each of the following parts, deduct a half point if the gradee uses the wrong input data, and hence gets the wrong statistics as output (for example using range(100) instead of range(101)).

Part (a): X/1.5 points

Grant 0.5 points for each statistic successfully computed using Sage's inbuilt methods.

Part (b): X/1.5 points

Grant 0.5 points for each statistic successfully computed using rpy2.

Part (c): X/1.5 points

Grant 0.5 points for each statistic successfully computed using r.eval or %r.

Part (d): X/1.5 points

Grant 0.5 points for each statistic successfully computed using scipy/numpy. Note that the scipy statistics methods are deprecated, so it's fine if the gradee uses numpy in its place instead.

Part (e): X/1 points

Grant 0.5 points for the successful computation of the mean and standard deviation using stats.TimeSeries. Note that stats.TimeSeries doesn't have a median method (the gradee should point this out, but it's okay if they don't).

Part (f): X/4 points

This required the gradee to write their own code. The mean function is worth 1 point, while the median and standard deviation functions are each worth 1.5 points. In each case, award full grade if the gradee's functions successfully compute the relevant statistic not just on [1..100] but on a number of datasets (test the functions on a few small lists, and make sure the outputs agree with the above methods). Don't forget to test for unsorted datasets too. Award partial grade if the code contains errors/is broken in some way according to your own discretion.


Question 2: X/9 points

Your comments here.

The first 10^6 integers have median 1000001/2 = 500000.5 and mean 1000001/2 = 500000.5. The biased standard deviation is 3/2*sqrt(37037037037) = 288675.13459... and the unbiased (sample) standard deviation is 500*sqrt(1000001/3) = 288675.27893... Either of the last two answers is fine in the gradee's code.

This is a timing question, so don't deduct points from your gradee if the outputs are wrong, providing it's the same code they used in question 1. If some some strange reason the gradee has used completely different code to compute the statistics of 1..10^6 and gets it wrong, use your own judgment to mark down as necessary.

The timing of parts (a) to (f) is each worth 1.5 points. For each part:
award 1.5 points: if the gradee successfully lists code that times (i.e uses timeit() - or time in the case of slow functions) the computing of all three statistics on 1..10^6
1 point: One of the statistics is missing; or the timings are listed but the code is missing; or the wrong data have been used (i.e. anything other than 1 to 1000000 inclusive)
0.5 points: Timings have not been produced, but some effort has been made toward the problem; or only one of the three statistics has been timed;
0 points: The timing of this part has not been attempted.

Technically, the question asks which approach is fastest and which slowest, so the gradee should point this out. However, it's fine if it's readily apparent from their timings.


...

Eddie Tsay

unread,
May 27, 2011, 3:40:28 PM5/27/11
to 480...@googlegroups.com
Total: 20/20 points.

Question 1: 11/11 points

Everything was done correctly here. Kevin's written-from-scratch functions work without any issues and are able to handles unsorted lists. This assignment was pretty straight forward so not much else to say here.

Part (a): 1.5/1.5 points

Done correctly. Range was appropriate and answers matches those found in grading guidelines.

Part (b): 1.5/1.5 points

Done correctly. Range was appropriate and answers matches those found in grading guidelines.

Part (c): 1.5/1.5 points

Done correctly. Range was appropriate and answers matches those found in grading guidelines.

Part (d): X/1.5 points

Done correctly. Range was appropriate and answers matches those found in grading guidelines.

Part (e): X/1 points

Done correctly. Range was appropriate and answers matches those found in grading guidelines.

Part (f): X/4 points

Tested the following:

L1 = [2,4,7,213,6,45, 23, 87,23,17] and L2: l = [2,4,7,213,6,45, 23, 87,17]

All three functions worked correctly. Median returns the average of the middle two numbers of the sorted list. Kevin's median functions handles unsorted lists without issue.


Question 2: 9/9 points

Kevin interpreted the timing question as which interfaces were fastest as a whole (mean, sd, and median timings combined) rather than individually. However, because he showed all his timings in previous sections, no points were taken off for this.

However, it may be worth noting that I found his Time Series timings to be slower than I would have anticipated. I was getting speeds in the nanoseconds so I'm wondering if his code somehow caused time series to be significantly slower. Try using Time Series directly...you'll see that it's super fast!
Reply all
Reply to author
Forward
0 new messages