CSC 151-02, Fall 2006 : Schedule : Lab 41
Summary: We explore further techniques for visualizing a simple multivariate data set.
Contents:
a. We'll be working in both DrScheme and GIMP, so open a new DrScheme window and a new GIMP window. In the GIMP, open a ScriptFu console. In that console, load our course GIMP library.
(load "/home/rebelsky/Web/Courses/CS151/2006F/Examples/gimp.scm")
b. If you have not done so already, make the file us1.txt
as described in
the previous lab.
a. Make a copy of datavis.scm.
b. Scan through that file to make sure that you understand the purpose of the various procedures. (The preprocess procedure is the most important one.)
c. As most of you noted on the first day exploring data visualization,
it's a pain to manually preprocess the data from the file. Hence, the preprocess procedure should do it for you.
d. Define a list of data points with
(define data-points (preprocess "/home/username/Desktop/us1.txt"))
a. Return to the previous lab and complete any exercises you had not previously completed.
b. Make sure that the plot procedures you wrote in the previous
laboratory (and any other related procedures) are in your library for
this laboratory (datavis.scm).
a. Expand each vector in data-points by adding a
GNP-per-capita value.
b. Write a procedure, (vmax vecs pos), that, given a list
of vectors, vecs, and a position, pos, finds
the largest value at position pos in each vector. For
example,
> (define vectors (list (vector 1 2 4 8) (vector 2 2 2 2) (vector 0 5 0 5)))
> (vmax vectors 0)
2
> (vmax vectors 1)
5
> (vmax vectors 2)
4
> (vmax vectors 3)
8
c. Write a similar procedure, (vmin vecs pos), that computes
a corresponding minimum value.
d. Write a procedure, (vshift! vecs pos amt), that adds
amt to the value at position pos in
each vector in vecs and returns the modified list.
e. Write a procedure, (vscale! vecs pos amt), that multiplies
by amt the value at position pos in each vector
in vecs and returns the modified list.
f. Add the following procedure to your library for this lab
(define normalize
(lambda (vecs pos)
(let* ((maxval (vmax vecs pos))
(minval (vmin vecs pos))
(scale (- maxval minval)))
(vscale! (vshift! vecs pos (- minval)) pos (/ 1 scale)))))
g. Normalize the values in data-points. For example, you
might write,
(normalize data-points 0)
(normalize data-points 1)
(normalize data-points 2)
(normalize data-points 3)
h. Rewrite plot to accept normalized values.
i. Graph the values in the vector with
(map (lambda (point) (plot img point)) data-points)
Now that all of the values are normalized, you can use any of the values
as the x value, any of the values as the y value, and any of the values
as the color value or radius. Write a variant of plot that
makes different choices about the index of each.
Janet Davis (davisjan@cs.grinnell.edu)
Created November 29, 2006 based on http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2006F/Labs/more-multivariate-visualization.html