C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-03-2009, 04:14 PM   #1
Registered User
 
Join Date: Nov 2009
Posts: 4
Beginner Needs Help (Least Squares Analysis

I'm a beginner. I need to create a very basic C program. Basically the program has to perform least square analysis on 8 sets of data. The program needs to read the values (magnitude and velocity) from the keyboard. Magnitude is the x value and logvelocity is the y value. The program does work but its not giving me the correct results. Some help will be much appreciate. I have attached my attempt. Please keep it as simple as possible.

Thanks a lot.
Attached Images
 
kd001 is offline   Reply With Quote
Old 11-03-2009, 04:20 PM   #2
Jack of many languages
 
Dino's Avatar
 
Join Date: Nov 2007
Location: Katy, Texas
Posts: 2,070
I don't see any structure or mechanical errors with the code. Must be a formula issue.
__________________
Mac and Windows cross platform programmer. Ruby lover.
Dino is offline   Reply With Quote
Old 11-03-2009, 04:28 PM   #3
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,809
I don't see any formula issues compared to Linear least squares - Wikipedia, the free encyclopedia either at first glance. First thing I would check, you're using "log", which computes ln. If you want to compute log, you need to use "log10".
tabstop is offline   Reply With Quote
Old 11-03-2009, 04:31 PM   #4
Registered User
 
Join Date: Sep 2008
Location: Toronto, Canada
Posts: 521
You are not using the array logv[], but are assigning the logarithm of v[] into y[]...
So maybe it has something to do with that. Formula/correct variable issue.
nonoob is offline   Reply With Quote
Old 11-03-2009, 04:35 PM   #5
Registered User
 
Join Date: Nov 2009
Posts: 4
These are the formulae. For some reason the program is not doing that:
Attached Images
 

Last edited by kd001; 11-03-2009 at 04:37 PM.
kd001 is offline   Reply With Quote
Old 11-03-2009, 04:41 PM   #6
Registered User
 
Join Date: Nov 2009
Posts: 4
'tabstop' may be onto something. I should calculate log10velocity so when I get the chance I will try changing it to log10.
kd001 is offline   Reply With Quote
Old 11-03-2009, 05:31 PM   #7
Senior software engineer
 
brewbuck's Avatar
 
Join Date: Mar 2007
Location: Portland, OR
Posts: 5,761
Quote:
Originally Posted by kd001 View Post
The program does work but its not giving me the correct results.
That's a strange definition of "works."
__________________
"Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot
brewbuck is offline   Reply With Quote
Old 11-04-2009, 02:51 AM   #8
Registered User
 
Join Date: Nov 2009
Posts: 4
Quote:
Originally Posted by brewbuck View Post
That's a strange definition of "works."
By works I just meant it compiles and runs.


Anyway changing from log to log10 solved the problem. Thanks to all those who gave their advice.
kd001 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Generating an image of squares? vopo C# Programming 3 10-21-2008 10:15 AM
Same old beginner question... Sharmz C Programming 15 08-04-2008 11:48 AM
Forced moves trouble!! Zishaan Game Programming 0 03-27-2007 06:57 PM
Dev-C++ Profile Analysis Orborde C++ Programming 0 05-28-2005 01:37 AM
rhetorical analysis and why it is for YOU! doubleanti A Brief History of Cprogramming.com 2 03-30-2003 02:11 PM


All times are GMT -6. The time now is 02:12 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22