>-----Original Message----- >From: John Pearson [mailto:xero@CMC.NET] >Sent: 31 March 2004 06:56 >To: PICLIST@MITVMA.MIT.EDU >Subject: [OT:] linear regression analysis > > >I am not very good at math. Please assume I am younger than 9 >or older than 40. > >I want my mpu to be able to create values for a linear >regression equation from 4 values that are entered, example: > >When A = 6, B = 2.1 >When A = 30, B = 0 > >How do I come up with the equation to corrolate B from A >(besides using analysis software). Hopefully I can program my >mpu to determine the equation needed as I change the values. > >Thank you >John A straight line has the form y = mx + c where m is the slope and c is the offset. m = dy/dx (i.e. change in y relative to the change in x) m = (0-2.1)/(30-6) = -2.1/24 = -0.0875 (this is value of the slope) c = the value of y when x = 0. After finding the slope you simply need to plug one of the original sets of values back into the equation: y = mx + c (m is known at this stage) y = (-0.0875x) + c Rearange to get c: c = y - (-0.0875x) Put one of the original sets of values in c = 2.1 - (-0.0875 * 6) = 2.625 The equation of your straight line is therefore y = -0.0875x + 2.625 FWIW this is not difficult to do on a PIC, even without using floating point math. Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= Any questions about Bookham's E-Mail service should be directed to postmaster@bookham.com. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu