Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5970177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:20:13+00:00 2026-05-22T20:20:13+00:00

I want to do Least Squares Fitting in Javascript in a web browser. Currently

  • 0

I want to do Least Squares Fitting in Javascript in a web browser.

Currently users enter data point information using HTML text inputs and then I grab that data with jQuery and graph it with Flot.

After the user had entered in their data points I would like to present them with a “line of best fit”. I imagine I would calculate the linear, polynomial, exponential and logarithmic equations and then choose the one with the highest R^2 value.

I can’t seem to find any libraries that will help me to do this though. I stumbled upon jStat, but it is completely missing documentation (as far as I can find) and after digging through the the source code it doesn’t seem to have any linear regression functionality built in–I’m basing this purely on function names however.

Does anyone know any Javascript libraries that offer simple regression analysis?


The hope would be that I could use the library like so…

If I had some set of scatter points in an array var points = [[3,4],[15,45],...[23,78]], I would be able to hand that to some function like lin_reg(points) and it would return something like [7.12,3] if the linear equation was y = 7.12 x + 3.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:20:14+00:00Added an answer on May 22, 2026 at 8:20 pm

    What kind of linear regression? For something simple like least squares, I’d just program it myself:

    http://mathworld.wolfram.com/LeastSquaresFitting.html

    The math is not too hard to follow there, give it a shot for an hour or so and let me know if it’s too hard, I can try it.

    EDIT:

    Found someone that did it:

    http://dracoblue.net/dev/linear-least-squares-in-javascript/159/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the simplest way (least error-prone, least lines of code, however you want
I want to style the last TD in a table without using a CSS
I want a data structure that will allow querying how many items in last
I got a grid with two points. I want to calculate the amount squares
In my game, I want to layout squares along the edges of a monochrome
I want to get the last result returned from this query. How do I
I have a variable last_login and want to output a message if the last
I want every cell in each row except the last in each row. I
On my blog, I want to display the all the posts from the last
FromIp contains 192.168.1.1 . I want to get the last number, but I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.