2

If I was to create interpolated splines from a large amount of data (about 400 charts, 500,000 values each), how could I then access the coordinates of those splines from another software quickly and efficiently?

Initially I intended to run a regression on the data and use the resulting formula in my delphi program, but that turned out to be a bigger pain than I thought.

I am currently using Matlab but I can use another software if need be.

Edit: It is probably relevant that this data represents the empirical cumulative distribution of some other data (which I already have in a database).

Here is what one of these charts would look like.example

The emphasis is on speed of access. I intend to use this data to run simulations on financial data.

Mike Furlender
  • 3,869
  • 5
  • 47
  • 75

4 Answers4

1

If you are also familiar with C, you could use Matlab coder or something similar to get an intermediate library to connect your Delphi program and MATLAB together. Interfacing Delphi and C code is, albeit a tad tedious, certainly possible (or it was back in the days of Delphi 7). Or you could even write the algorithm in MATLAB, convert the code to C using Matlab coder and from within Delphi call the generated C library.

Perhaps a bit overkill, but you can store your data in a database (e.g. MySQL) from MATLAB and retrieve them from Delphi.

Finally: is Delphi a real constraint? You could also use MATLAB to do the simulations, as you might have the same tools (or even more) available for MATLAB than in Delphi. Afterwards you can just share the results, which I suppose is less speed critical.

Egon
  • 4,757
  • 1
  • 23
  • 38
1

My initial guess at doing this efficiently would be to create a memory mapped file in MATLAB using memmapfile, stuff a look-up table with your data into that, then open the memory mapped file in your Delphi code and read the data from that file.

Jacob
  • 3,626
  • 2
  • 20
  • 26
1

MATLAB has a command for converting a spline into a piecewise polynomial. You can then extract the breaks and the coefficients of each piece of polynomial with unmkpp, and evaluate them in another program.

rwong
  • 6,062
  • 1
  • 23
  • 51
0

The fastest is most likely a look-up table that you save to disk and that you load and use in your simulation code (although: why not run the simulation in Matlab?)

You can evaluate the spline for a finely-grained list of values of x using FNVAL, and use the closest value of x to look up the cdf.

Jonas
  • 74,690
  • 10
  • 137
  • 177