I have been working on putting together a basic nu...
# mathematics
a
I have been working on putting together a basic numerical methods library and was wondering what I could do to build an api primarily for this linear regression class. Also what is the best way to assert equals when the known values differ in significant figures from the actualValue. https://github.com/jalexcole/NumericalMethods/blob/master/src/main/kotlin/curveFitting/regression/LinearRegression.kt
a
Not sure about the first part of your question. In junit the last parameter of assertEquals for values of type double should be the delta which represents the error, so for 2 decimal places you would use like 0.005
a
I have been working through a textbook of mine to build out a kotlin numerical methods package, however I am unsure of how to build an api to make each item more accessible. I could just copy the scipy api but I think I should be a bit more creative.
a
are you making a library or standalone app?
I wouldn't worry too much about the api at this point but as you add more things you might get more ideas how to better use it. For example on LinearRegression you have a dataset as input (array of double) but later you might decide to have a dataset as its own class if there are other usages for it, but right now that refactor doesn't make sense.
a
I think I will use kmath objects as the data sets later on and will tack that on in a constructor once I complete my own implementations of each numerical method in my book.
@Andrew What would you recommend for a dataset class? Would this become its own numpy like object?
a
Yes I can see it being useful later, for example your LinearRegression takes 1 or 2 arrays in the constructor. If you had several other classes that did the same thing it would make sense to move that to a Dataset class then those classes just accepted a dataset. Really depends on what else you plan on adding.
a
I have been thinking about writing my own NDArray class with operator overloads. Would this be the same as the DataSet class?
a
I'm not sure how operator overloads work with those so might be something different
a
I was looking at doing vector math and wanted something easier. This would be similar to making two objects
Copy code
val c = a + b
The same thing exists in matlab with .* or ./ operators for dealing with vectors or matricies.
a
yeah that make sense, just wanted to be clear this is different than a dataset which usually holds time series data but a N-dimensional array for vector operations would be a different use (even if the underlying data is an array of float/double)
a
Do you think you could post an example DataSet Class?