Informatics 42 • Winter 2008 • David G. Kay • UC Irvine
Sixth Homework
Get your work checked and signed off by a classmate, then show it to your TA in lab by Wednesday, February 20.
(a) Write regular expressions to match each of the following patterns. Note that these are natural language descriptions, so they will certainly be ambiguous; disambiguate them as you see fit and note what decisions you made. In some cases you may not be able to match the described set completely; it's fine to make some simplifying assumptions.
* Comma-separated dollars-and-cents amounts (e.g., $1,234.56 and $17). The differences between this expression and the one we did in class are (a) the "cents" portion isn't required and (b) leading zeroes are allowed.
* Lines that are empty or all blanks. (The caret ("^") matches the start of a line and the dollar sign matches the end of the line.)
* Email addresses
* URLs in HTML anchor tags (e.g., <A href="http://www.ics.uci.edu/~kay">)
* Lines containing exactly one integer (perhaps surrounded by non-numeric characters)
(b) Every day you download some investment information from a web site whose server's load varies on different days of the week. On Monday through Thursday, the download takes you 15 minutes. On Friday, it takes you 25 minutes. On Saturday and Sunday, it takes you 10 minutes. What is your overall expected download time (i.e., imagine you don't know what day it is)?
(c) In the California Lottery game SuperLotto, a player would pay $1.00 to pick six different numbers (between 1 and 51) for the next draw. (We're describing the original SuperLotto game, not the current SuperLotto Plus with a separate "Mega" number; the probabilities for SuperLotto Plus are a little more complicated.) Every Wednesday and Saturday, the Lottery draws six numbers. If the player's six numbers match the Lottery's six numbers, the player wins the multi-million-dollar jackpot (or splits it with any other players who also picked the same six winning numbers). If nobody matches the six winning numbers, the jackpot "rolls over" to the next draw; that is, the jackpot amount for the draw with no winners is added to the jackpot for the next draw. If many draws go by with no winners, the jackpot can get very large; it has been over $100,000,000.
Which of the following statements are supported by the principles of probability? Give a yes or no answer to each, with a few words of explanation.
(c.1) If you pay $2.00 for two different sets of numbers, you are twice as likely to win as if you paid $1.00.
(c.2) If you pay $100.00 for 100 different sets of numbers, you are 100 times as likely to win as if you paid $1.00.
(c.3) If you buy one ticket for every drawing for ten years, your chances of winning are roughly a thousand times greater than if you buy just one ticket.
(c.4) If you decide to play the same six numbers in every draw from now on, you should check the winning numbers in the past to be sure your numbers haven't come up already.
(c.5) If you play for a few months and not a single number you choose is included in the winning numbers, you are a little more likely to win the next draw (because you're "due").
(c.6) If you play for a few months and two or three of your numbers are included in the winning numbers of each draw, you are a little more likely to win the next draw (because you're "on a roll").
(c.7) Since 50% of the ticket revenues goes to prizes, in general the expected value of a $1.00 ticket is 50 cents.
(c.8) The expected value of your $1.00 ticket will be higher if you only play when the jackpot is over $20,000,000.
(c.9) Your probability of winning is greater if you pick numbers between 1 and 31 (because many people pick birthdates as their numbers).
(c.10) Your expected value is greater if you pick numbers greater than 31.
(c.11) (This part is entirely optional, for probability whizzes;we won't ask questions like these on tests.) Calculate the probability of winning the SuperLotto jackpot. Then, calculate the expected value of playing a $1.00 SuperLotto ticket. The hard part about this isn't the calculation; it's finding the payout amounts over the last year. They're not available at the California Lottery web site (www.calottery.com) and we don't know if they're available anywhere, so this is an opportunity for you to do some creative web searching.
(d) [from Patterns of Problem Solving by Moshe F. Rubinstein] In one brief sentence, how is information related to probability?
If you know that 5 people out of every 1000 have cancer, and if we have a perfectly accurate test that predicts whether a person has cancer, which of the following gives us more information:
* The test indicates that a person has cancer.
* The test indicates that a person does not have cancer.
(e) Make a small relevance tree (with five to ten "leaves") on any topic you like; then rank two or three alternatives on the tree you've designed. Be sure to state the criteria for the rating scales you use (e.g., 0: over $500; 1: $300-500; . . .) and pay attention to the "deal-breaking" bottom threshold; using a narrow scale, like 0 to 3, will make this easier.
(f) (We haven't talked about everything related to this part yet, but we will cover it in Tuesday morning's lecture.) An entrepreneur decides to open a car dealership. Suppose that four different franchises are available: Lexus, Saturn, recreational vehicles, or used cars. Suppose further that the states of nature can be summarized in four possibilities: booming economy, growing economy, stable economy, and depressed economy. The utilities of the outcomes under these conditions are summarized below in a payoff matrix:
Which alternative should the entrepreneur select under the optimist strategy? the pessimist strategy? the regretist strategy? For each strategy, give a different, plausible, real-world reason why the entrepreneur might choose that strategy in deciding what kind of cars to sell.
(g) Read the problem description for the amusement park simulator. You don't have to memorize every detail, but you do need to start getting familiar with what the program is suppsed to do.
Written by David G. Kay, Winter 2005, and modified Winter 2006; regular expression exercise written by David G. Kay, Winter 2001