SUNY Geneseo Department of Computer Science


Overview of the Scientific Method

{Date}

CSci 141, Spring 2004
Prof. Doug Baldwin

Return to List of Lectures

Previous Lecture


Misc

Hand out Lab 2

Next Thursday (1/29) I'm out of town

CS learning center is open

Questions?

Instrumentation code not measuring itself?

    // initialize an array:
    //	Measure how many assignments to array
    //	Measure time
    long start = System.currentTimeMillis();
    int count = 0;
    for ( i = 0; i < a.length; i++ ) {
        a[i] = 0;
        count = count + 1;
    }
    System.out.println( count );
    long end = System.currentTimeMillis();

Controls

    long start = System.currentTimeMillis();
    for ( i = 0; i < a.length; i++ ) {
        a[i] = 0;
    }
    long end = System.currentTimeMillis();
    ...
    long controlStart = System.currentTimeMillis();
    long controlEnd = System.currentTimeMillis();

Garbage collection?

        for ( int i = 0; i < n; i++ ) {
            Robot r = new Robot();
            .... currentTimeMillis();
            r.move();
            ... currentTimeMIllis();
        }
        Robot r = new Robot();
        long total = 0;
        for ( int i = 0; i < n; i++ ) {
            long start = System.currentTimeMillis();
            r.move();
            long end = System.currentTimeMIllis();
            total = total + (end-start);
        }
        .... total / n ...

Step counts do act well as surrogates for time

Northwest Corner Algorithm

Look at Finished Algorithm

Reading Summary

Sections 4.1 - 4.6

Scientific method

Scientific theory

Instrumentation and timing

Ensuring accuracy in computer timing

Errors

True values (?)

Error control/estimation

Try an Experiment

Hypothesis: spinning ball ties up my computer for ten minutes at a time

Procedure: Time the ball several times

Data: 70 sec, 68 sec

Analysis: average times

Conclusion: hypothesis is pretty far-fetched

Next

Start looking at methods of inquiry in connection with actually designing and coding algorithms

Conditionals (if-then, if-then-else, switch)

Read Sections 5.1 - 5.5


Next Lecture