News for hackers. Stuff that matters.
Re:Linear regression by hand by soVeryTired on Saturday January 20, 2018 @04:20PM (#16195483)
Yes, but why? Right tool for the right job and all that...
Re:Linear regression by hand by barrkel on Saturday January 20, 2018 @07:05PM (#16196159)
Normally the reason you write anything beyond trivial SQL is because you only have a small amount of code to run and lots of data to run it over. Pushing the code to the data is more efficient than pulling the data to the code.

The latter might be conceptually cleaner (though it's debatable, relational is a fairly nice programming model and a lot more consistent and well-founded than object orientation, for one), but it's seldom optimal.

Three orders of magnitude or more speedups are not unexpected by pushing the code to the data.

Re:Linear regression by hand by thaumaturgy on Saturday January 20, 2018 @08:30PM (#16196404)
You're basically spot on here. I have a bunch of rows that need to have trend data crunched and updated pretty frequently. Putting this into MySQL cut the server load quite a bit, and it isn't so much business logic that I feel bad about doing it.
Re:Linear regression by hand by taeric on Saturday January 20, 2018 @06:27PM (#16196003)
I would guess access to the data is a decent reason to try. No need to pump the data elsewhere, if this is available.

I share your doubt that this is worth it, to be clear.

Re:Linear regression by hand by thaumaturgy on Saturday January 20, 2018 @08:26PM (#16196394)
In this case the amount of data and the frequency with which it needs to be updated made handling this in MySQL more practical. I otherwise would've had to have some process querying and updating the records outside of MySQL and it turns out that that puts a whole lot more load on the server than if I just ask MySQL to do it.

And besides, what happened to the hacker ethos? "Because I can" should be justification enough. :-)

Re:Linear regression by hand by taeric on Sunday January 21, 2018 @10:05PM (#16201578)
Is is cool to hear that it works! And just because one doubts something, doesn't mean one shouldn't necessarily try it. Especially if I'm the one doubting. :)