Machine learning in trading: theory, models, practice and algo-trading - page 3280

 
fxsaber #:

Trying to quickly find similar short strings in a long string.

Is it more optimal to use Alglib ?

It has QCF

 
Maxim Dmitrievsky #:

There's a QCF in there, too

Doesn't seem to have made it into the MQL distribution. Is NumPy counting fast?

 
Maxim Dmitrievsky #:

There's a QCF in there, too

Tried it, it's giving me some rubbish.

#include <Math\Alglib\fasttransforms.mqh>

const vector<double> GetCorr2( double &Array[], double &Pattern[] )
{
  double Corr[];  
  CCorr::CorrR1D(Array, ArraySize(Array), Pattern, ArraySize(Pattern), Corr);
  
  // ArrayRemove(Corr, 0, ArraySize(Pattern) - 1);  
  
  vector<double> Res;
  Res.Swap(Corr);

  return(Res);
}

void OnStart()
{
  const double ArrayTmp[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  const double PatternTmp[] = {1, 2, 3};
  
  double Array[];
  double Pattern[];
  
  ArrayCopy(Array, ArrayTmp);
  ArrayCopy(Pattern, PatternTmp);
  
  Print(GetCorr2(Array, Pattern)); // [14,20,26,32,38,44,50,26,9,3,8]
}
 
fxsaber #:

Tried it, it comes up with some rubbish.

np.correlate([1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3], mode='full' )


array([ 3, 8, 14, 20, 26, 32, 38, 44, 44, 50, 26, 9])

 
fxsaber #:

Doesn't seem to have made it into the MQL distribution. Is NumPy counting fast?

Python loops are slow, so I didn't think of a way to do it

 
Maxim Dmitrievsky #:

Python loops are slow, so I didn't have to figure out how to do it.

Cycles have nothing to do with QCF.

 
fxsaber #:

Cycles have nothing to do with it if the QCF.

ccf instantaneous

 
Maxim Dmitrievsky #:
array([ 3, 8, 14, 20, 26, 32, 38, 44, 50, 26, 9])

What do these numbers represent?

 
fxsaber #:

What do these numbers represent?

unnormalised cross-correlations )

cross-covariances
 
Maxim Dmitrievsky #:

unnormalised cross-correlations )

cross-covariance.

Well, you need Pearson.