Hi Uko,
i assume you mean if the y-values are all the same? (if the x-values are all the same a solution would not be possible.) of course you can catch the ZeroDivideError and then set correlationCoefficient to nil. this way you can get eg the 'lr asEstimatedPolynomial' part and such things as slope & intercept. but i personally would be hesitant to change this in the publicly downloadable version without some further thinking, the ZeroDivideError makes sense from the pov of the book and i am not sure whether the error parts in DhbLinearRegression return the correct values if one does this.
werner
On Sunday, February 21, 2016 at 10:48:55 PM UTC+1, Yuriy Tymchuk wrote:Hi,this was super useful.One thing that I’ve noticed, is that if all the values are the same, a zero divide exception happens when correlationCoefficient is calculated. Does if have to be like that, or there is a way to treat this case?Cheers.UkoOn 18 Feb 2016, at 01:01, werner kassens <[hidden email]> wrote:To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].Hi Yuriy,
do you mean something like this:
x:=#(1 2 4 8 9).
y:=#(3 4 5 6 7).
lr:=DhbLinearRegression new.
points:=(1 to:x size) collect:[:i|( (x at:i)@(y at:i))].
points do:[:i|lr add:i].
p:=lr asEstimatedPolynomial . "-->(371/127) + (55/127) X"
b := RTGrapher new.
ds := RTDataSet new.
ds noDot.
ds points: (0 to: 10 by:2).
ds x: #yourself.
ds y: [:i|p value:i].
ds connectColor: (Color red).
b add: ds.
ds := RTDataSet new.
ds points: points.
ds x: #x.
ds y: #y.
b add: ds.
b build.
b view openWithMenu .
??
werner
On Wednesday, February 17, 2016 at 4:21:38 PM UTC+1, Yuriy Tymchuk wrote:Hi,
I have an array of Xs and corresponding one of Ys. How can I get the least square fit? Because when I look at the class it uses histograms and distributions, etc…
Cheers :)
Uko--
You received this message because you are subscribed to the Google Groups "SciSmalltalk" group.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "SciSmalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Free forum by Nabble | Edit this page |