130 likes | 202 Views
Explore data scaling methods for lab data analysis. Learn how to scale data to fit a specific range and visualize it using histograms. Get ready to work on your project proposal!
E N D
CISC 130 - Today’s Class • Recap • Project Proposal • Problem 12 • Final notes on Problem 11 R. Smith - University of St Thomas - Minnesota
Recap • Problem 11 • Problem 12 • Objectives • Scaling R. Smith - University of St Thomas - Minnesota
Projects!! • Proposal Due Thursday! (Tomorrow) • Plan due Next Wednesday! • Let’s look at the Project… R. Smith - University of St Thomas - Minnesota
Assignment 12: Scaling • Date Due: Next Monday • The problem: • Taking a set of data and scaling it to fit a particular range • A common lab data problem • What we’ll do • Read in a file of data to be scaled • Calculate scaled values • Print out the original data w/scaled horizontal histogram R. Smith - University of St Thomas - Minnesota
Assignment 12: The File • Line-oriented file again, like in A11 • Name/Number instead of Number/Name • Separated by tab character “\t” • Read “names” into one array • Read “numbers” into a separate array • Use a third integer array for scaled values R. Smith - University of St Thomas - Minnesota
How Scaling Works • Scan the raw data in the array • Find the minimum and maximum values • Minimum maps to 0 in scaled values • Maximum maps to 31 in scaled values • Calculate the scaling ratio • Range of desired values / range of actual values • scale = 31.0 / (max – min) • A real number, not an int • Apply the ratio and round the result • Subtract ‘min’ before scaling • Use “rint()” function from math.h • Save scaled values in the scaled array R. Smith - University of St Thomas - Minnesota
Unscaled Values 200 1000 253 600 999 823 410 Scaled Values 0 31 2 16 31 24 8 Example Scaling R. Smith - University of St Thomas - Minnesota
The Histogram • Horizontal Format • Left side of display: name and unscaled value • Right side: histogram of scaled value R. Smith - University of St Thomas - Minnesota
Sample Input • Moose Mountain 986 • Mystery Mountain 650 • Eagle Mountain 650 • Ullr Mountain 350 • Welch Village 360 • Spirit Mountain 700 • Keystone 3128 • Steamboat Springs 3668 • Sunday River 2340 R. Smith - University of St Thomas - Minnesota
Looking at the Assignment • It’s almost all recycling from other programs • One nit – you need a char->decimal conversion • Let’s play with that. R. Smith - University of St Thomas - Minnesota
Looking at the Assignment • The assignment outlines how to recycle functions you’ve written already. • If you have questions, ask. R. Smith - University of St Thomas - Minnesota
Final Notes on Assignment 11 • The comments must match your code! • If you think there may be discrepancies, fix them and resubmit! • You should be able to do this without breaking your code. • But– be sure to test your code after you make any changes, even if you’re just changing comments. R. Smith - University of St Thomas - Minnesota
Creative Commons License This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. R. Smith - University of St Thomas - Minnesota