Back Home Up


Exercices ranking

  1. Copy the file "grades.sav" from the IDL exercises directory to your local directory.  Then, using the RESTORE command, "restore" it to your IDL session. 
  2. The save file contained the variable "GRADELIST".  This is a set of actual final point scores for a UVa course.
  3. How many students were in the class?
  4. Determine the MEAN, MEDIAN, MAXIMUM, MINIMUM, and standard deviation (using VARIANCE) for the set of scores.  
  5. Using the SORT function, define a new list (call it "SCOREORDER") of scores in order from lowest to highest value.  Verify.
  6. Now define and verify a new list (call it "RANKSCORE") of scores in order from highest to lowest value.  (Hint: use REVERSE)
  7. Now define an auxiliary vector ("RANK") which gives the rank of each student in the class (assigning 1 to the student with the highest grade)
  8. Using a (one-line) FOR loop, an appropriately defined format string, and the PRINT command, print on your terminal the rank and score of the students in order from highest to lowest. Hint:  the definition for an IDL format string might look like the following (IDL format statements are similar, but not identical, to those in FORTRAN). FORMOUT='(A12,3X,I3,3X,F8.3,3X,E10.3)' and the command to print would look like this:
  9. Use your rank-listing capability to determine the median of
             the grade distribution.  Does it agree with the value
             returned by MEDIAN?
  10. Now assign letter grades to the students.  Assume you are a tough grader and use a strict curve where the top 10% of the class gets an "A", the next 10% gets a "B" and so on.  The lower 60% of the class will get an F in this scheme (appropriate, e.g., for a pre-Med class). Using STRARR, define a string array named "LETTER" to hold the letter grades for the students.  
  11. Fill it with blanks initially. Consult the ranked list of scores from your terminal printouts and determine the letter grade break points. Then assign values to the "LETTER" array using those breakpoints.  [Hint: use the WHERE function.]  "LETTER" should be in the order of the original "GRADELIST".
  12. Verify the assignments by using a FOR statement and a new format definition to print on your terminal a list of rankings, numerical scores, and letter grades in ranked order.
  13. Now create an output file on your disk and output to it, in the original (not ranked) order: the numerical grade, the class rank, and the final letter grade for each student. [Hint: You already have defined an appropriate format string.  The other commands you will need are GET_LUN, OPENW, PRINTF, and CLOSE.]
  14. Verify your results (e.g. use $MORE).
  15. Now reverse the process and read the disk file back into your IDL session, using variables with different names. Verify the results




IDL courses C. Morisset 2004 IA/UNAM V 2.2

Back Home Up