Param `mean` in Random.multivariateNormal doesn't need to be a KtNDArray
It is 1-D array_like thing and can be just a std Kotiln collection.
Instead of
Random.multivariateNormal(mean=array(listOf(-2,0)), ...
would be nice to have:
Random.multivariateNormal(mean=listOf(-2,0), ...
Alright.
I thought that the user will work mainly with ndarray, but in cases where mean is calculated in ndarray, it will be possible to convert using toList().
If KtNDArray implements Iterable then even toList wont be necessary, providing that mean argument had type Iterable.
There is one more problem. If we use ndarray, then we simply pass a pointer to it in python, and if we use jvm structure (array, list), then we need to convert it to python array. This is additional overhead.
Isn't the overhead there in any case? mean=array(listOf(-2,0)
Would be nice also to relax the type of parameter cov because now I have to create KtNDArrays when I don't really need them.
Compare how Python is so much more concise than Kotlin:
Py: https://nbviewer.jupyter.org/github/JetBrains/lets-plot/blob/master/docs/examples/jupyter-notebooks/density_2d.ipynb Kt: https://nbviewer.jupyter.org/github/JetBrains/lets-plot-kotlin/blob/master/docs/examples/jupyter-notebooks/density_2d.ipynb
Isn't the overhead there in any case?
Yes, there is overhead. Only in case of reuse mean will give an improvement.
I agree that it is necessary to support iterable for mean. I will save the signature with KtNDArray and add method with signature for Iterable. I will also find similar methods where this is necessary.
Of course, all this would be easier if KtNDarray implemented the Iterable interface. Here I described what are the difficulties of this.