Difference between revisions of "EGR 103/Fall 2018/Lab 3/InLab"
Jump to navigation
Jump to search
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | Here's a general overview of what I went over during the lab; be sure to also check the [[Fall_2018/Lab_3 Lab 3]] self-guided tour and rad the lab document! Things in those two items are not replicated below. | + | Here's a general overview of what I went over during the lab; be sure to also check the [[EGR 103/Fall_2018/Lab_3 Lab 3]] self-guided tour and rad the lab document! Things in those two items are not replicated below. |
== Problem 1 == | == Problem 1 == | ||
Line 34: | Line 34: | ||
== Problem 4 == | == Problem 4 == | ||
+ | * Default is to roll a single six-sided die (roll_dice() is same as roll_dice(1, 6)) | ||
+ | * Two ways to think about calculations: roll a single die N times or roll N dice once -- the way you think about it will inform your writing your code. | ||
+ | * Test with numbers that are easy to check first - for instance roll_dice(1, 1) or roll_dice(10,2). | ||
+ | * Assume the inputs are valid integers. | ||
+ | |||
+ | == Problem 5 == | ||
+ | * Uniformly distributed means within a particular range, it is equally likely to get any number within that range. | ||
+ | * Normally distributed has a higher probability near the average; there's no minimum or maximum necessarily, but with an average of 0 and a standard deviation of 1, almost all the values will be concentrated between about -3 and 3. | ||
+ | * Quite a bit of the code is already done - you need to add the code to get the number of values in each of your distributions and then the two lines to create a set of numbers for the uniformly distributed numbers and the normally distributed numbers. | ||
+ | * The code will already plot the histogram - which is a bar graph telling you how many of your values are within a particular smaller range of values (i.e. "how many are between 0 and 0.1", "how many are between 0.1 and 0.2," etc.). Deciding the number of bins is important as to have large enough collections to make sense but not so large as to not see the interesting information. | ||
+ | ** "Birthday century" not that useful since just split into 20th and 21st for the class | ||
+ | ** "Birthday day of year" not that useful since 366 bins for around 30 people | ||
+ | ** "Birthday month of year" could be useful - might still be too many bins for 30 people | ||
+ | * You need to add all the code that calculates and then prints the statistical values noted in the lab manual. | ||
+ | * You will copy that from the screen and paste it in your lab report. | ||
+ | |||
+ | == Generally == | ||
+ | * Do work every day. | ||
+ | * Only work on one problem at a time -- if you get done - great! Go away and come back later. If you don't - great! Go away and come back later. | ||
+ | * There are comments in the .tex file before the lines that bring in the diary and figures -- once you have created those, you can go ahead and uncomment those, save, rerun latex and dvipdf, and then look at the file. | ||
+ | * Make sure you look at your entire lab report before you turn it in! We will only be able to grade what you submit in your lab report! |
Latest revision as of 21:44, 17 September 2018
Here's a general overview of what I went over during the lab; be sure to also check the EGR 103/Fall_2018/Lab_3 Lab 3 self-guided tour and rad the lab document! Things in those two items are not replicated below.
Problem 1
- Input is assumed to be some number of seconds
- Output would be a tuple of hours, minutes, and seconds
- Examples:
- hms(60) should be 0, 1, 0
- hms(4012) should be 1, 6, 52 -- there are 3600 second in an hour, and 3600 fits once in 4012. Of the remaining 412 seconds, there are 60 seconds in a minute which gives 6 whole minutes and 52 seconds left.
- As usual, figure out how you work the problem, then write the code.
- Note that a//b will give you the number of whole b's in a; a%b will give you what is left over after taking out as many whole b's as possible
- Neither a nor b need to be an integer!
- 4.2 // 1.5 is 2.0 and 4.2 % 1.5 is 1.2
- The code I gave takes input and returns a tuple of all zeros - these should eventually be replaced with the hours, minutes, and remaining seconds you calculate.
- You do not need to make any changes to the test_time code - simply run it and enter your NetID when asked. It will print to your screen and save to a time_diary.txt file; the former is so you can see what the tester did and the latter is so you can include that text in your lab report.
- The code to import the diary has a comment in LaTeX - once you have created the diary, be sure to go into emacs and into your lab3.tex code to remove the comments in front of the \lstinputlisting line appropriate for that diary.
Problem 2
- First three inputs are required, fourth is an option input (default is 0)
- Book has equation for Law of Cosines\[c^2=a^2+b^2-2ab\cos(\theta_c)\]
- Note that to draw a closed triangle you need to give the plot command a total of four coordinate pairs.
- Current code has imports and function definition line; you need ad calculating angles, making plot, and returning values.
- When evaluating logic, generally any non-zero, non-False value is considered True. This means
if draw:
will run the code it controls if the draw variable contains anything other then 0 or boolean False. - Loops and ifs and whiles need to have at least one active line of code to work - a good placeholder is
pass
- The test code will ask for your NetID and then run your program 4 times. It will produce a diary for the lab report and four graphs for the appendix.
- If one of the triangle PDFs or diary files is open, the test code may not be able to run due to permissions. If you preview PDF files, close them before re-running the tester.
- Your code does not need to check for valid values - assume the user gives you sides that work.
Problem 3
- Components between 0 and 2.375
- For single numbers a and b: max(a, b) returns the number closest to +infinity; min(a, b) returns the number closest to -infinity.
- Calculations over the course of a season of about 100 are excellent.
- Calculations for a single game may have a wild range.
- The test code will ask for your NetID and run your program several times and save a diary.
Problem 4
- Default is to roll a single six-sided die (roll_dice() is same as roll_dice(1, 6))
- Two ways to think about calculations: roll a single die N times or roll N dice once -- the way you think about it will inform your writing your code.
- Test with numbers that are easy to check first - for instance roll_dice(1, 1) or roll_dice(10,2).
- Assume the inputs are valid integers.
Problem 5
- Uniformly distributed means within a particular range, it is equally likely to get any number within that range.
- Normally distributed has a higher probability near the average; there's no minimum or maximum necessarily, but with an average of 0 and a standard deviation of 1, almost all the values will be concentrated between about -3 and 3.
- Quite a bit of the code is already done - you need to add the code to get the number of values in each of your distributions and then the two lines to create a set of numbers for the uniformly distributed numbers and the normally distributed numbers.
- The code will already plot the histogram - which is a bar graph telling you how many of your values are within a particular smaller range of values (i.e. "how many are between 0 and 0.1", "how many are between 0.1 and 0.2," etc.). Deciding the number of bins is important as to have large enough collections to make sense but not so large as to not see the interesting information.
- "Birthday century" not that useful since just split into 20th and 21st for the class
- "Birthday day of year" not that useful since 366 bins for around 30 people
- "Birthday month of year" could be useful - might still be too many bins for 30 people
- You need to add all the code that calculates and then prints the statistical values noted in the lab manual.
- You will copy that from the screen and paste it in your lab report.
Generally
- Do work every day.
- Only work on one problem at a time -- if you get done - great! Go away and come back later. If you don't - great! Go away and come back later.
- There are comments in the .tex file before the lines that bring in the diary and figures -- once you have created those, you can go ahead and uncomment those, save, rerun latex and dvipdf, and then look at the file.
- Make sure you look at your entire lab report before you turn it in! We will only be able to grade what you submit in your lab report!