[ANN] First release of `Curve_sampling`

announce

#1

Hi,

It is my pleasure to announce the first release of the package curve-sampling which provides adaptive sampling of functions (and more generally parametric curves) so they can be represented graphically with a minimal number of evaluations. Curve_sampling takes the viewpoint that the evaluation function may be costly, so one specifies the number of evaluations one wants. For example, a representation of x ↦ x sin(1/x) with 227 evaluations gives (rendered with Gnuplot but Curve_sampling is independent of a rendering engine):
graph1

The chosen evaluation points are displayed on the following graph:
graph1_p

As a comparison, here is the graph produced by Mathematica for the same function (which uses a different procedure which does not allow to limit the number of evaluations, only the recursion depth, here 5, yielding to the evaluation at 227 points):
Plot%20Points10%20MaxRecursion5%20eval227

With 389 evaluations (recursion depth of 6 for Mathematica), the graphs become:
graph2
graph2_p
and
Plot%20Points10%20MaxRecursion6%20eval389

Enjoy the library and, if you have functions that are not sampled well with the current algorithm, do not hesitate to fill an issue.

Have a nice day,
C.


#2

Cool! what do you imagine as a workflow for graphical output? is there a way to feed the sampled points to matplotlib, for example?


#3

There is Curve_sampling.to_file that saves the data to a file as lines of x y with blank lines when the curve needs to be interrupted. It can certainly be read from Python. Another possibility would be to use py to import the data without using a file — there is Curve_sampling.to_list to get it from the sampling but additional exports may be added (a Seq export is available on OCaml ≥ 4.07). If you try that latter route, let me know.