Tips for Assignment 7


In your function chi we have already defined a variable called expect. This variable plays the role of the matrix E in the description you were given of chi-square. Variable expect is a matrix that has the same shape as the parameter table (i.e. the same number of rows and columns). Don't worry if you do not follow the mathmatics used to create expect; it uses matrix multiplication (the kind you do not need to know about).

IMPORTANT!   When you complete function/file chi.m, be SURE to put a semicolon (;) at the end of each line. Otherwise, when you run distrib.m, you'll get about a hundred or more pages of junk!

On Part A, Question 9, it is highly recommended that you type a semicolon at the end of x=linspace(0,20); unless you wish to pointlessly see a hundred numbers. NOTE: if you have already done this, you do NOT have to redo the
question.

As specified on Part B, Step 4 (1), be SURE you have a semicolon at the end of truechart = truedistrib(dataTotal);
unless you wish to pointlessly see two thousand numbers.

Clarification on Terminology and Variable Names. The definition of "percentile" is: A number (from 0 to 100) indicating what percent of a distribution is equal to or below it. The variable named "percentile" in the handout is a chart
listing values of the chi-square statistic at percentile levels spaced by 1% at a time. Thus, a better name for this variable
is "chart", rather than "percentile". This naming convention is more consistent with the rest of the assignment.

In particular, in your lookup function, you are (1) taking a "chart" and a chi-square value "chisq", (2) computing the percentile of "chisq" (the percent of values below it), and (3) returning this percentile (this number (percent)).

Assingment 7 part B step 4 will be optional: Step 4 is rather simple, but some of you are getting error messages due to the versions of Matlab you are running. If you are running on a PC you may need to make sure the names of your functions are only 8 characters long. In addition, if you are running a student version of Matlab that is early than version 5.1 you may get other errors in this part. Because this is a minor part of the assignment (mainly to have some fun) we are making it optional. An updated file you can use will be posted later today.

Important note on using old versions of Matlab. We are using the latest student version (5.1) of Matlab (we are also using the latest academic version of CodeWarrior). But some of you are using earlier versions and are therefore running into problems. Here are the major consequences.

  1. In Part B, you may have to comment out the "echo" commands within script files tables.m and distrib.m to get them to run
    properly.
  2. Step 4 of Part B is now optional: It just won't work on older versions. If you wish to do Step 4, then use a machine (Mac or PC) in the public labs.
  3. Some of the bonuses are impossible, e.g. the plot in Part B: bar3 and ribbon are new commands in version 5.1.

If you are dead set on doing Step 4 on an old version of Matlab, the following steps might suffice (they should work,
but we are not guaranteeing this):

  1. (For PC users only) Rename function file "truedistrib.m" to "truedis.m", replace "truedistrib" inside the same function file with "truedis", and call "truedis(dataTotal);" instead of "truedistrib(dataTotal);".
  2. within the two statements "cards(i:k-1)=j;" and "cards2(i:k-1)=j;", replace the j's by "j(ones(1,k-i))".

Do NOT replace the colons (:) with commas (,), as this totally changes the meaning of the statements.


Last update:  06/08/00 11:55