2009-02-27

Post date: Feb 27, 2009 8:45:18 PM

    • (session 1 only) Given a PRNG that generates samples Xi with a known mean μ and variance σ2, we can construct a PRNG that generates samples Xi' with a specified mean μ' and variance σ'2 by letting Xi' = a + b * Xi. We get μ' = a + b * μ, and σ' = bσ. Solve for a and b.
    • (session 2 only) Went over some C language constructs (enum, union) that might be helpful for describing events (see event.h below).
    • Implemented a simple integer queue based on singly linked list (see queue.h, queue.c below)
    • Unit testing the queue (see unittest_main.c below).

Instruction for downloading and installing "check", the unit testing framework that I used:

    • Download the source package (check-0.9.6.tar.gz).
    • Unpack and change into source directory: tar zxf check-0.9.6.tar.gz && cd check-0.9.6
    • Configure: ./configure --prefix=$HOME/local
    • Feel free to substitute $HOME/local to anywhere you see fit. This is the destination that "check" will be installed to. Be sure to modify the Makefile to tell it the correct prefix to use.
    • Make and make install: make && make install
    • From this point on, you can remove the source directory and the tar.gz package, but keep the "prefix" directory (i.e. the destination).
    • Clean up sources: cd .. && rm -rf check-0.9.6
    • Clean up downloaded package: rm check-0.9.6.tar.gz

A complete transcription of these steps can be found in "installing-check.txt" below.

To make sure that unit testing works, try to break code in queue.c and see how the test fails. First comment out the lines commented by marker 1, make and run the unit test. You should see that the deq_null test fails. Restore queue.c to its original content. Now, comment out the line commented by marker 2, make and run the unit test. You should see that enq_deq_enq_deq test fails.