Linear Regression

Line of Best Fit & Logarithms

Page 1 of 1

3 Replies - 6935 Views - Last Post: 28 July 2010 - 10:00 AM Rate Topic: -----

#1 Sh4d0ws  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 40
  • Joined: 23-July 10

Linear Regression

Posted 28 July 2010 - 09:16 AM

Hello, I am currently working on a project, and I have been asked to do lines of best fit for a set of data. I have looked into it slightly and found that what I want to do is called Linear Regression, however I do not know how to do this in Java. If anyone can help me it would be very appreciated. I currently do not even have a start on this, so anything that you can offer would be helpful.

I cannot show you the actual data, however I will do a mock-up so that you understand what I am working with.

1. We have an array of double's which stores the values (these values are typically -0.01 to 0.070). The number of the array (e.g. array[10] is the x-coordinate on the graph.

2. The x-scale values are 250-750, and the values on the y-scale are 0.00-0.10

3. All I need is a straight line (although knowing how to do quadratic/cubic lines would be helpful because I believe it is moving to that next in the project).

4. Everything else (its a GUI) is already done (e.g. actionlistener's, buttons, the actual graph, etc) is already complete and I do not require help with that.




Cheers
Sh4d0ws

This post has been edited by Sh4d0ws: 28 July 2010 - 09:21 AM


Is This A Good Question/Topic? 1
  • +

Replies To: Linear Regression

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10595
  • View blog
  • Posts: 39,246
  • Joined: 27-December 08

Re: Linear Regression

Posted 28 July 2010 - 09:18 AM

Take a look at this link describing how to calculate Linear Regression. Once you have the formula, it's a matter of plugging in points for a drawLine() invocation on your Graphics object.
Was This Post Helpful? 2
  • +
  • -

#3 Sh4d0ws  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 40
  • Joined: 23-July 10

Re: Linear Regression

Posted 28 July 2010 - 09:56 AM

Very helpful, thank you macosxnerd101 for a prompt response.
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10595
  • View blog
  • Posts: 39,246
  • Joined: 27-December 08

Re: Linear Regression

Posted 28 July 2010 - 10:00 AM

Glad I could help! :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1