English Русский 中文 Español Deutsch 日本語 Português Français Italiano Türkçe
preview
MQL5의 ALGLIB 수치 해석 라이브러리

MQL5의 ALGLIB 수치 해석 라이브러리

MetaTrader 5 | 15 7월 2024, 11:20
34 0
MetaQuotes
MetaQuotes

소개

금융 시장은 엄청난 양의 복잡한 관계를 가진 데이터를 생성합니다. 이를 분석하려면 가장 현대적인 응용 수학을 사용해야 합니다. 재무 데이터의 높은 복잡성과 분석의 단순성 및 효율성을 성공적으로 결합한다는 것은 쉽지 않은 작업입니다. ALGLIB은 수치 기법 및 데이터 분석 알고리즘 작업을 위해 특별히 설계된 고성능 라이브러리로 금융 시장 분석에 있어 신뢰할 수 있는 조력자입니다.

ALGLIB 다용도성
오늘날 ALGLIB은 수치법 작업을 위한 최고의 라이브러리 중 하나로 인정받고 있으며 여러 프로그래밍 언어(C++, C#, Java, Python, Delphi)와 운영 체제(Windows 및 POSIX, Linux 포함)를 지원합니다.

ALGLIB의 많은 기능 중 눈에 띄는 것은 다음과 같습니다:

  • 선형 대수학: 데이터 분석에 중요한 알고리즘, 고유값(EVD) 및 특이값(SVD) 메서드를 포함합니다.
  • 방정식 풀기: 선형 및 비선형 방정식 시스템을 모두 지원하므로 복잡한 재무 프로세스를 모델링할 때 유용합니다.
  • 보간 및 근사치: 다양한 데이터 보간 및 근사화 방법을 지원하므로 시장 동향을 분석하고 예측하는 데 유용합니다.
  • 최적화: ALGLIB은 최적의 솔루션을 찾는 알고리즘을 제공합니다. 이는 우리가 투자 포트폴리오 및 각종 재무 결정을 최적화하는 데 중요한 역할을 합니다.
  • 수치 통합: 금융 상품을 평가하는 데 유용한 정적분 계산을 허용합니다.
  • 머신 러닝: 데이터 분석, 분류, 회귀, 신경망 사용까지 포함하므로 시장 트렌드를 예측할 수 있는 새로운 가능성이 열립니다.


ALGLIB의 장점

ALGLIB를 금융 데이터로 작업할 때 선택하는 이유는 무엇일까요?

라이브러리의 주요 이점은 다음과 같습니다:

  • 이동성: ALGLIB은 다양한 컴파일러를 사용하여 다양한 플랫폼에서 쉽게 컴파일 되므로 다양한 배경을 가진 여러 개발자들이 사용할 수 있습니다.
  • 사용 편의성: 여러 프로그래밍 언어를 지원하므로 여러분은 새로운 구문을 배울 필요 없이 가장 익숙한 언어를 선택할 수 있습니다.
  • 오픈 소스: ALGLIB은 오픈 소스이며 GPL 2+ 사용 조건에 따라 사용할 수 있습니다. 따라서 과학 연구와 상업 프로젝트 모두에 사용할 수 있습니다.
  • 상업용 사용자 지원: 상업용 사용자는 ALGLIB을 사용할 때 법적으로 사용권에 대한 보호를 받을수 있는라이선스를 구매할 수 있습니다.

또한 라이브러리에는 제안된 메서드의 주요 기능성에 대한 방대한 테스트 사례 모음이 포함되어 있습니다. 이렇게 하면 테스트 및 감지된 오류를 프로젝트 작성자에게 전달할 수 있습니다. 라이브러리에 대한 자세한 정보는 프로젝트 웹사이트 https://www.alglib.net/ 에서 확인할 수 있습니다.

ALGLIB은 2012년에 MQL5 언어에서 사용하기 위해 처음 적용되었습니다. 이 적용은 버전 3.5에서 라이브러리를 변환한 것입니다. 그로부터 10년이 넘는 시간이 흘렀습니다. 이 기간 동안 ALGLIB는 금융 시장 거래 분야의 개발자와 분석가들 사이에서 널리 알려지게 되었습니다. 수년 동안 개발팀은 라이브러리를 개선하기 위해 적극적으로 노력하였고 그래서 새로운 클래스, 기능 추가 및 개선 사항을 포함하여 70개 이상의 변경 사항을 적용했습니다.

또한 기존 라이브러리 클래스가 행렬과 벡터를 사용하도록 재설계되었으며 ALGLIB 3.19에 도입된 새로운 기능이 추가되었다는 점에 유의하세요. 이제 복소수 작업에 'Complex' 데이터 유형이 사용됩니다. 모든 소스 코드는 통합된 디자인 스타일에 따라 수정되고 구조화되었습니다.

안타깝게도 MQL5용 ALGLIB 라이브러리 버전 3.19에서 내용이 상당히 많이 변경되었기 때문에 이전 버전과의 호환성은 제공되지 않습니다. 프로젝트에 ALGLIB 버전 3.5를 적용하는 사용자들은 프로그램을 철저히 검토하고 필요한 사항을 조정하는 것이 좋습니다.

라이브러리 자체뿐만 아니라 테스트 스크립트도 업데이트되었습니다. 이제 클래스용은 91개이고 인터페이스용은 152개입니다. 이를 통해 라이브러리 기능을 보다 안정적이고 포괄적으로 테스트할 수 있습니다.

ALGLIB의 새 버전은 여기에서 다운로드할 수 있습니다: ALGLIB - 수치 분석 라이브러리 - MetaTrader 5용 라이브러리 및 MetaTrader 5 플랫폼의 일부(\MQL5\Include\Math\Alglib\, \MQL5\Scripts\UnitTests\Alglib\의 테스트 케이스 포함)입니다.


1. ALGLIB 3.19의 새로운 기능(버전 3.5 이후의 변경 사항 목록)

3.19:

  • ALGLIB 3.19.0의 가장 중요한 기능은 박판 스플라인, 바이하모닉 스플라인 및 멀티쿼드릭을 지원하는 대규모 데이터 집합을 처리하기 위한 새로운 RBF(방사형 기저 함수) 솔버입니다. 이 솔버는 보간 및 피팅(평활화)의 문제를 모두 지원합니다;
  • 새로운 RBF 알고리즘은 도메인 분해 방법을 사용하여 선형 시스템을 푸는 데 사용됩니다. 그 결과 다른 오픈 소스 구현에 필요한 O(N) 메모리 요구 사항과 O(N2) 실행 시간보다 크게 개선된 O(N2) 메모리 요구 사항과 O(N3) 실행 시간을 제공합니다. 이 알고리즘은 100,000개 이상의 포인트가 있는 데이터 집합에 사용할 수 있습니다.

3.18:

  • 선형 방정식을 위한 Sparse GMRES 솔버가 추가되었습니다;
  • AMD 알고리즘의 성능이 향상되었습니다(행이 밀집된 행렬의 처리를 최적화할 때);
  • 새로운 콜레스키 분해와 솔버 코드의 광범위한 최적화를 통해 선형 프로그래밍(LP) 및 이차 프로그래밍(QP)을 위한 내부 점 솔버의 속도가 향상되었습니다.

3.17:

  • 전문가용 함수 및 사용자 친화적인 래퍼가 포함된 스파스 초극초분해와 해당 스파스 직접 선형 솔버가 추가되었습니다. permutation padding reduction 및 정의되지 않은 인수분해를 활성화했습니다;
  • large-scale interior point linear programming (LP) 문제를 위한 솔버가 추가되었습니다;
  • large-scale interior point semidefinite quadratic programming (QP) 문제를 위한 솔버가 추가되었습니다.

3.16:

  • 밀도 및 희소 버전에서 내부 점 이차 프로그래밍(QP) 문제용 솔버를 구현했습니다;
  • O(N*logN) 실행 시간으로 페널티가 적용된 큐빅 스플라인을 빠르게 피팅 하는 새로운 서브루틴이 추가되었습니다;
  • 비선형 프로그래밍을 위한 새로운 SQP 솔버가 추가되었습니다;
  • 대규모 랜덤 포리스트에 압축 바이너리 저장 형식을 도입했습니다(메모리 사용량 3.7~5.7배 감소);
  • CRS 및 스카이라인 행렬에 대한 sparsegemv() 함수를 추가했습니다;
  • CDF 및 PDF 이변량 정규 함수를 구현했습니다.
  • 이제 QP 솔버가 라그랑주 승수를 보고합니다;
  • 이제 QP 솔버는 양방향 선형 제약 조건을 지원합니다;
  • SLP 솔버의 안정성이 향상되었습니다;
  • 보다 정확한 솔루션을 위해 LP 솔버의 참조 요소 선택이 개선되었습니다.

3.15:

  • 시계열에 대한 특이 스펙트럼 분석(SSA;Singular Spectrum Analysis, "애벌레") 알고리즘을 구현했습니다. 구현을 최적화 하였으며 트렌드 추출, 예측, 평균 예측 및 빠른 증분 모델 업데이트가 포함되었습니다;
  • 스카이라인(SKS) 형식으로 저장된 희소 선형 시스템을 위한 직접 솔버가 추가되었습니다;
  • 부등식이 많은 이차방정식 문제와 관련하여 QP-DENSE-AUL 솔버의 성능이 개선되었습니다;
  • BLEIC 및 QP-BLEIC 솔버의 속도가 크게 향상되었습니다(최대 4배). 솔버의 내부 코드를 수정하여 제약 조건 처리를 크게 개선했습니다;
  • 하위 차원 고유값 솔버에 대한 열 트리거링 지원이 추가되었습니다. 일련의 관련 고유값 문제를 풀 때 이전에 찾은 기본 해를 새로운 풀이 세션에서의 시작점으로 재사용할 수 있습니다;
  • SKS 형식의 스트라이프 행렬의 생성을 간소화했습니다(sparsecreatesksband() 함수);
  • 실수를 위한 새로운 BLAS 레벨 2 함수 세트가 추가되었습니다: GEMV, SYMV, TRSV;
  • 이제 sparseset() 함수가 SKS 행렬을 지원합니다;
  • 이제 minqp 솔버는 이차 항의 대각선을 기준으로 가변 스케일의 자동 계산을 지원합니다.

3.12:

  • 이제 rbfsetpoints() 함수는 입력 데이터에 NAN/INF가 있는지 확인합니다;
  • K-평균 클러스터링 및 고유값 뒤로 반복 알고리즘은 이제 초기화에 결정론적 시드 값을 사용하여 여러 실행에서 결과를 재현할 수 있습니다;
  • QQP 솔버에서 이차 항의 자동 스케일링이 잘못되는 작은 버그가 수정되었습니다.

3.11:

  • 선형 제약 비선형 최소제곱(MinLM 및 LSFit)을 수행하는 기능이 추가되었습니다. 이제 매개변수에 대한 선형 제약 조건을 사용하여 비선형 근사치를 수행할 수 있습니다;
  • 데이터에 대한 대략적인 최소 외곽선, 최소 면적 및 최대 내접 N-구(2D - 외접 원, 3D - 내접 구)에 대한 지원이 추가되었습니다;
  • MinNLC 솔버의 안정성을 개선하고 또 다른 전처리 모드인 '정밀 안정'을 추가했습니다;
  • '활성' 상태의 변수에 대해서만 제한을 두는 새로운 최적화 도구인 MinBC를 추가했습니다. 이러한 제한을 통해 일반적인 선형 제약 조건에서는 불가능 했던 활성화 전략이 가능합니다;
  • C# 및 C++용 ALGLIB 버전에 스트리밍 직렬화/역직렬화가 추가되었습니다;
  • 서브스페이스 방식을 사용한 직접/희소/순서 외 고유값 솔버와 서브스페이스 방식을 사용한 빠른 절단 주성분 분석(PCA)을 구현했습니다;
  • 일부 데이터 세트에서 몇 배 더 빠르고 100,000개 이상의 포인트를 처리할 수 있는 병렬 처리 지원을 통해 계층적 RBF가 개선되었습니다;
  • 선형 제약 이차적 프로그래밍(QP) 문제 솔버가 추가되었습니다;
  • 직사각형 영역에 대한 쿼리 및 스레드 안전 버전의 쿼리 함수가 포함된 개선된 kd 트리.

3.10:

  • CSV 가져오기 기능 추가 - 이제 CSV 파일에서 2D 행렬을 읽을 수 있습니다;
  • 비선형, 비평활 및 일관되지 않은 제약된 문제를 최적화하기 위해 AGS(적응형 그라데이션 샘플링) 알고리즘을 도입하였고 결과적으로 ALGLIB은 비평활 최적화를 지원하는 몇 안 되는 상용 패키지 중 하나가 되었습니다;
  • 계층적 클러스터링을 위한 Ward 메서드를 추가했습니다;
  • 조건 수 추정 및 반복 보정이 없는 경량의 선형 솔버를 구현하여 '기능이 풍부한' 아날로그 솔버보다 몇 배 더 빠릅니다.

3.9:

  • 희소/고밀도 선형 대수 지원이 대폭 개선되었습니다: SKS 희소 행렬 저장 형식, SKS 기반 행렬을 위한 선형 대수 연산, SKS용 콜레스키 인수분해기, 희소 행렬을 위한 다양한 추가 함수;
  • 솔버 및 최적화 도구 개선: 변수에 제약이 있는 제한된 이차 프로그래밍 문제를 위한 새로운 솔버인 QuickQP, 비선형 증강 라그랑지안 최적화 도구, 개선된 BLEIC 최적화 도구, 다항식 솔버 및 기타 여러 가지 사소한 개선 사항이 있습니다;
  • 보간/피팅 기능 추가: 4/5개의 파라미터를 사용한 로지스틱 곡선 피팅, 라머-더글라스-피커(RDP) 알고리즘;
  • 선형 판별 분석(LDA) 알고리즘의 속도가 개선되었습니다.

3.8:

  • 순위 기능(설명적 통계)이 추가되었습니다- 데이터를 순위로 바꾸는 기능입니다;
  • 경계 및 선형 제약 조건이 있는 희소하고 일관되지 않은 이차 프로그래밍 문제를 해결할 수 있는 새로운 솔버인 QP-BLEIC을 도입했습니다;
  • FFT 성능 개선(성능은 향상되었지만 여전히 단일 스레드);
  • 여러 가지 사소한 개선 사항(BLEIC 옵티마이저의 단계적 개선, MLP의 가중치 초기화 개선, 5점 미만의 아키마 스플라인).

3.7:

  • BLEIC 옵티마이저를 대폭 재설계했습니다. 먼저 엘비라 일라리오노바가 제안한 새로운 3단계 액티브 세트 알고리즘을 사용하여 그라데이션 투영과 L-BFGS 제약 조건 동일성 반복을 결합합니다. 둘째 알고리즘에 더 이상 중첩된 외부/내부 반복이 없기 때문에 알고리즘에 대한 보다 투명한 중지 기준을 설정할 수 있습니다. 셋째 퇴화된 제약 조건을 올바르게 처리하는 새로운 제약 조건 활성화/비활성화 전략을 사용합니다;
  • ALGLIB에서 신경망에 대한 지원이 대폭 개선되었습니다. 동일한 설정과 데이터로 여러 네트워크의 훈련을 대폭 간소화하는 새로운 훈련 인터페이스가 도입되었습니다. 이제 희소 행렬을 사용하여 훈련 집합을 지정할 수 있습니다;
  • 향상된 클러스터링 지원 - 새 버전의 ALGLIB에는 클러스터링 하위 패키지로부터의 계층적 클러스터 분석 알고리즘이 포함되어 있습니다. 이 알고리즘에는 여러 거리 메트릭(유클리드, 1-노름, 무한대-노름, 피어슨-스피어만 상관관계 기반 메트릭, 코사인 거리)과 여러 링크 유형(단일 링크, 전체 링크, 평균 링크)이 포함되어 있습니다. 새로운 알고리즘 이전에 존재했던 K-평균 클러스터링 기능이 새로운 클러스터링 알고리즘과 결합되었습니다;
  • 이제 희소 선형 솔버(CG 및 LSQR)는 자동 대각선 전처리기를 지원합니다;
  • 이제 선형/비선형 최소제곱 솔버(lsfit 서브 패키지)가 비율 오류를 보고합니다;
  • 이제 희소 행렬 기능에 해시 테이블과 CRS 보기 간 변환을 위한 새로운 함수와 SparseRewriteExisting 함수에 대한 성능 개선이 포함되어 있습니다.

3.6:

  • 이제 이차 최적화 도구는 경계 및 선형 부등식/부등식의 임의 조합을 지원합니다. 새 버전의 옵티마이저는 증강 라그랑주 방식과 액티브 세트 방식을 조합하여 사용합니다;
  • 이제 Spline1D 모듈은 단조로운 입방 스플라인을 사용한 보간을 지원합니다;
  • 벡터 쌍선형 및 쌍입방 스플라인에 대한 지원이 추가되었습니다;
  • 스칼라 및 벡터 삼선형(3D) 스플라인에 대한 지원이 추가되었습니다;
  • 희소 행렬에 대한 지원 개선: 0이 아닌 요소의 효율적인 열거를 위해 SparseEnumerate() 함수를 사용하고 CRS 형식으로 저장된 행렬의 경우 SparseGet() 속도가 빨라졌습니다;
  • 최적화 및 비선형 근사 알고리즘(하위 패키지 LSFit, MinLM, MinBLEIC, MinLBFGS, MinCG)이 사용자가 제공한 기울기의 유효성(수치 프로그램에서 가장 흔하게 발생하는 오류)을 확인할 수 있습니다.

2. 과학적 연구에서의 ALGLIB 라이브러리

오픈 소스로 제공되고 비상업적 프로젝트에 무료로 사용할 수 있는 ALGLIB은 과학 연구 분야에서 중요한 도구로 자리 잡았습니다. 또한 다양하고 복잡한 문제를 해결하는 데 성공적으로 사용되고 있습니다.

ALGLIB의 중요한 영향력은 맞춤형 소프트웨어 개발에서 분명하게 드러나는데 ALGLIB의 많은 알고리즘은 혁신적인 솔루션을 만드는 데 기초가 됩니다.

또한 ALGLIB의 단일 스레드 알고리즘은 약 200만 개의 방정식을 포함하며 방대한 방정식 시스템을 해결하기 위해 설계된 반복 알고리즘의 병렬 버전 개발의 벤치마크 및 기준점 역할을 합니다. 이는 ALGLIB 라이브러리가 제공하는 알고리즘의 신뢰성과 뛰어난 효율성을 입증하는 것입니다.

연구자들은 ALGLIB 알고리즘의 높은 품질과 효율성에 주목하였으며 그들의 기초 연구 및 엔지니어링을 비롯한 다양한 분야의 복잡한 연구 문제를 해결하는 데 선호하고 있습니다.


2.1. ALGLIB in optimization problems

2014: Hugo J. Kuijf, Susanne J. van Veluw, Mirjam I. Geerlings, Max A. Viergever, Geert Jan Biessels & Koen L. Vincken. Automatic Extraction of the Midsagittal Surface from Brain MR Images using the Kullback–Leibler Measure. Neuroinform 12, 395–403 (2014)

The midsagittal plane computed in the previous section was used to initialize the computation of the midsagittal surface. The midsagittal surface was represented as a bicubic spline, as implemented in ALGLIB (Bochkanov and Bystritsky (2012)). Control points for the spline were placed in a regular grid on the computed midsagittal plane, with distance m between the control points.

2017: Vadim Bulavintsev, A GPU-enabled Black-box Optimization in Application to Dispersion-based Geoacoustic Inversion, 2017, in Yu. G. Evtushenko, M. Yu. Khachay, O. V. Khamisov, Yu. A. Kochetov, V.U. Malkova, M.A. Posypkin (eds.): Proceedings of the OPTIMA-2017 Conference, Petrovac, Montenegro, 02-Oct-2017

For reference, we provide the double-precision version based on the AlgLib library [Bochkanov & Bystritsky, 2016], that we used in our previous work [Zaikin et al., press]. The AlgLib library includes a state-of-the-art implementation of the bisection algorithm, thoroughly tuned to produce the most accurate results possible with the modern CPUs floating point units (FPUs). Our CPU-based implementation of bisection algorithm can not boast such accuracy. However, it is notably faster than AlgLib due to its simplicity. That is why, our and AlgLib-based algorithm’s results are different. The discrepancy between the outputs (residue) of the same algorithm on the CPU and GPU is the result of the different implementations of floating-point units on these platforms.

2.2. ALGLIB in interpolation problems

2021: Jasek K., Pasternak M., Miluski W., Bugaj J., Grabka M, Application of Gaussian Radial Basis Functions for Fast Spatial Imaging of Ground Penetration Radar Data Obtained on an Irregular Grid. Electronics 2021, 10, 2965.

The ALGLIB package implements both kinds of RBFs: the global Gaussian function and compactly supported. The classical Gaussian function takes small values already at a distance of about 3R0 from the center and can easily be modified to be compactly supported.

In this paper, the RBF-ML algorithm implemented in the ALGLIB package was used. It has three parameters: the initial radius, R0, the number of layers, NL, and the regularisation coefficient, l. This algorithm builds a hierarchy of models with decreasing radii [13]. In the initial (optional) iteration, the algorithm builds a linear least squares model. The values predicted by the linear model are subtracted from the function values at the nodes, and the residual vector is passed to the next iteration. In the first iteration, a traditional RBF model with a radius equal to R0 is built. However, it does not use a dense solver and does not try to solve the problem exactly. It solves the least squares problem by performing a fixed number (approximately 50) of LSQR [22] iterations. Usually, the first iteration is sufficient. Additional iterations will not improve the situation because with such a large radius, the linear system is ill-conditioned. The values predicted by the first layer of the RBF model are subtracted from the function values at the nodes, and, again, the residual vector is passed to the next iteration. With each successive iteration, the radius is halved by performing the same constant number of LSQR iterations, and the forecasts of the new models are subtracted from the residual vector.

In all subsequent iterations, a fine regularisation can be applied to improve the convergence of the LSQR solver. Larger values for the regularisation factor can help reduce data noise. Another way of controlled smoothing is to select the appropriate number of layers. Figure 2 shows an example of B-scan and a method of approximation by a hierarchical model. Subsequent layers have a radius that is twice as small and explain the residues after the previous layer. As the radius decreases, the finer details of the B-scan are reproduced.

The hierarchical algorithm has several significant advantages:

• Gaussian CS-RBFs produce linear systems with sparse matrices, enabling the use of the sparse LSQR solver, which can work with the rank defect matrix;
• The time of the model building depends on the number of points, N, as N logN in contrast to simple RBF’s implementations with O(N3) efficiency;
• An iterative algorithm (successive layers correct the errors of the previous ones) creates a robust model, even with a very large initial radius. Successive layers have smaller radii and correct the inaccuracy introduced by the previous layer;
• The multi-layer model allows for control smoothing both by changing the regularisation coefficient and by a different number of layers.

The presented hierarchical RBF approximation algorithm is one of the most efficient algorithms for processing large, scattered data sets. Its implementation, located in the ALGLIB library, enables simple software development, which can be successfully used to analyse GPR images.


2022: Ruiz M., Nieto J., Costa V., Craciunescu T., Peluso E., Vega J, Murari A, JET Contributors, Acceleration of an Algorithm Based on the Maximum Likelihood Bolometric Tomography for the Determination of Uncertainties in the Radiation Emission on JET Using Heterogeneous Platforms. Appl. Sci. 2022, 12, 6798.

ALGLIB is a numeric library focused on solving general numerical problems. It can be used with different programming languages such as C++, C#, and Delphi. It offers a great variety of functions for different science fields. In this specific application, it is required to interpolate the 2D data arrays that can or cannot be equally spaced (nonuniformly distributed). The development of the function implementing the equivalent to griddata requires the use of ALGLIB 2D interpolation functions for sparse/non-uniform data. For the fitting part, the least square solver function is used, for which two options are available: BlockLLS 또는 FastDDDM. The FastDDDM option was chosen to achieve the best possible performance.

ArrayFire provides a complete API that solves the most common functionalities implemented with MATLAB language. Therefore, it can be considered that porting MATLAB to C++ using ArrayFire API is relatively straightforward, and some parts of the code are even equivalent line by line. Nevertheless, ArrayFire does not include some powerful functions available in MATLAB. For example, the function “griddata” allows different types of interpolations using uniform and not-uniform input data distribution. This function in MATLAB has some parts of the internal code visible to the user, but other parts are not available, making it impossible to reproduce its calculations. While ArrayFire version 3.8.0 includes a function for interpolation, it expects that input data will be uniformly organized. To solve this problem, we chose the open-source library ALGLIB, which provides a set of functions for 2D interpolation that can be used to circumvent the problem.

While most of the code and functions of the algorithm in MATLAB were translated into C++ and optimized, others could not be translated directly. The reason is that there is no information about the internal calculations of some of the functions in MATLAB. This implies that the results obtained in both implementations are slightly different. These differences are mainly evident in the implementation of the griddata function. For this application, it has been used with the “bicubic splines” interpolation method, incorporated in the FastDDM solver belonging to the ALGLIB library.

2.3. ALGLIB algorithms as a benchmark for comparison

2015: Tarek Ibn Ziad, M. & Alkabani, Yousra & El-Kharashi, M. W. & Salah, Khaled & Abdelsalam, Mohamed. (2015). Accelerating electromagnetic simulations: A hardware emulation approach. 10.1109/ICECS.2015.7440386.

...Ibn Ziad et al. implemented a Jacobi iterative solver on a physical hardware emulation platform to accelerate the finite element solver of an EM simulator [5]. They demonstrated the efficiency of their solution via implementing a twodimensional (2D) edge element code for solving Maxwell’s equations for metamaterials using FEM. Their design achieved 101x speed-up over the same pure software implementation on MATLAB [13]  and 35x over the best iterative software solver from ALGLIB C++ library [14] in case of solving 2 million equations.

In this paper, we present a scalable architecture that can efficiently accelerate the solver core of an EM simulator. The architecture is implemented on a physical hardware emulation platform and is compared to the state-of-the-art solvers. Experimental results show that the proposed solver is capable of 522x speed-up over the same pure software implementation on Matlab, 184x speed-up over the best iterative software solver from the ALGLIB C++ library, and 5x speed-up over another emulation-based hardware implementation from the literature, solving 2 million equations.

2016: Liu, Yongchao & Pan, Tony & Aluru, Srinivas (2016), Parallel Pairwise Correlation Computation On Intel Xeon Phi Clusters.

Using both artificial and real gene expression datasets, we have compared LightPCC to two CPU-based counterparts: a sequential C++ implementation in ALGLIB (http://www.alglib.net) and an implementation based on a parallel GEMM routine in Intel Math Kernel Library(MKL). Our experimental results showed that by using one 5110P Phi and 16 Phis, LightPCC is able to run up to 20.6× and 218.2× faster than ALGLIB, and up to 6.8× and 71.4× faster than singled-threaded MKL, respectively.

2.4. ALGLIB algorithms as part of specialized software

2015: Kraff S, Lindauer A, Joerger M, Salamone SJ, Jaehde U. Excel-Based Tool for Pharmacokinetically Guided Dose Adjustment of Paclitaxel. Ther Drug Monit. 2015 Dec;37(6):725-32

Methods: Population PK parameters of paclitaxel were taken from a published PK model. An Alglib VBA code was implemented in Excel 2007 to compute differential equations for the paclitaxel PK model. Maximum a posteriori Bayesian estimates of the PK parameters were determined with the Excel Solver using individual drug concentrations. Concentrations from 250 patients were simulated receiving 1 cycle of paclitaxel chemotherapy. Predictions of paclitaxel Tc > 0.05 μmol/L as calculated by the Excel tool were compared with NONMEM, whereby maximum a posteriori Bayesian estimates were obtained using the POSTHOC function.

2017: Hogland, John & Anderson, Nathaniel. (2017). Function Modeling Improves the Efficiency of Spatial Modeling Using Big Data from Remote Sensing. Big Data and Cognitive Computing.1.3.

While the statistical and machine learning transformations can be used to build surfaces and calculate records within a tabular field, they do not in themselves define the relationships between response and explanatory variables like a predictive model. To define these relationships, we built a suite of classes that perform a wide variety of statistical testing and predictive modeling using many of the optimization algorithms and mathematical procedures found within ALGLIB and Accord.net [15,16]

Furthermore, we introduce a new coding library that integrates Accord.NET and ALGLIB numeric libraries and uses lazy evaluation to facilitate a wide range of spatial, statistical, and machine learning procedures within a new GIS modeling framework called function modeling. Results from simulations show a 64.3% reduction in processing time and an 84.4% reduction in storage space attributable to function modeling. In an applied case study, this translated to a reduction in processing time from 2247 h to 488 h and a reduction is storage space from 152 terabytes to 913 gigabytes.


3. 금융 시장 분석을 위한 ALGLIB 라이브러리

MQL5용 라이브러리의 첫 번째 버전(ALGLIB 3.5)은 금융 데이터 분석에 널리 사용되며 최신 알고리즘을 사용하여 다양한 문제를 해결하고 있습니다.

아래는 ALGLIB 라이브러리의 클래스와 함수를 적극적으로 적용한 문서의 목록입니다:

따라서 ALGLIB 수학 라이브러리의 기능은 재무 데이터를 분석하는 데 유용한 도구로 밝혀졌습니다.


4. ALGLIB의 특이 스펙트럼 분석

새로운 버전의 ALGLIB 라이브러리에는 기존 메서드 외에도 이제 특이 스펙트럼 분석 메서드(SSA, "캐터필라"라고도 함)가 포함되어 있습니다. 이 메서드는 특히 예측 문제에서 재무 시계열 분석의 기능을 크게 확장합니다. SSA 알고리즘은 버전 3.15부터 사용할 수 있으며 구현이 최적화되었습니다. 트렌드 추출, 시계열 예측, 평균 예측 기능 등을 제공하며 빠른 증분 모델 업데이트가 가능합니다.


여러분은 이 메서드가 실제로 어떻게 작동하는지 숙지하고 트레이딩 전략을 개발할 때 이 방법을 사용한 경험을 공유해 주시기 바랍니다.

다음은 SSA 메서드 사용 예제가 포함된 테스트 스크립트입니다. 공식 라이브러리 도움말의 특이 스펙트럼 분석" 섹션에서 ALGLIB 라이브러리의 SSA 방법 사용 예제 및 세부 사항에 대한 추가 정보를 확인할 수 있습니다.

//+------------------------------------------------------------------+
//|                                                     SSA_Test.mq5 |
//|                                  Copyright 2023, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"

#include <Math\Alglib\alglib.mqh>

// Examples of SSA usage with ALGLIB
// https://www.alglib.net/translator/man/manual.cpp.html#example_ssa_d_basic
// https://www.alglib.net/translator/man/manual.cpp.html#example_ssВa_d_realtime
// https://www.alglib.net/translator/man/manual.cpp.html#example_ssa_d_forecast

//+------------------------------------------------------------------+
//| PrintMatrix                                                      |
//+------------------------------------------------------------------+
void PrintMatrix(CMatrixDouble &x)
  {
//--- print matrix
   string str="[";
   for(int i=0; i<x.Rows(); i++)
     {
      str+="[";
      for(int j=0; j<x.Cols(); j++)
        {
         str+=StringFormat("%f",x.Get(i,j));
         if(j<x.Cols()-1)
            str+=",";
        }
      str+="]";
      if(i<x.Rows()-1)
         str+=",";
     }
   str+="]";
   printf("%s",str);
  }
//+------------------------------------------------------------------+
//| PrintVector                                                      |
//+------------------------------------------------------------------+
void PrintVector(CRowDouble &x)
  {
//--- print vector
   string str="[";
   for(int i=0; i<x.Size(); i++)
     {
      str+=StringFormat("%f",x[i]);
      if(i<x.Size()-1)
         str+=",";
     }
   str+="]";
   printf("%s",str);
  }
//+------------------------------------------------------------------+
//| ssa_d_basic                                                      |
//+------------------------------------------------------------------+
//| Here we demonstrate SSA trend/noise separation for some toy      |
//| problem: small monotonically growing series X are analyzed with  |
//| 3-tick window and "top-K" version of SSA, which selects K largest|
//| singular vectors for analysis, with K=1.                         |
//+------------------------------------------------------------------+
int ssa_d_basic(void)
  {
//--- prepare input data
   double input_data[]= {0,0.5,1,1,1.5,2};
   CRowDouble x=input_data;
//--- first, we create SSA model, set its properties and add dataset.
//--- we use window with width=3 and configure model to use direct SSA algorithm which runs exact O(N*W^2) analysis - to extract one top singular vector.
//--- NOTE: SSA model may store and analyze more than one sequence (say, different sequences may correspond to data collected from different devices)
//--- ALGLIB wrapper class
   CAlglib alglib;
//--- SSA model
   CSSAModel ssa_model;
//--- create SSA model
   alglib.SSACreate(ssa_model);
//--- set window width for SSA model
   alglib.SSASetWindow(ssa_model,3);
//--- adds data sequence to SSA model
   alglib.SSAAddSequence(ssa_model,x);
//--- set SSA algorithm to "direct top-K" algorithm
   alglib.SSASetAlgoTopKDirect(ssa_model,1);
//--- now we begin analysis. Internally SSA model stores everything it needs:
//--- data, settings, solvers and so on. Right after first call to analysis-related function it will analyze dataset, build basis and perform analysis.
//--- subsequent calls to analysis functions will reuse previously computed basis, unless you invalidate it by changing model settings (or dataset).
//--- trend and noise
   CRowDouble trend,noise;
//--- build SSA basis using internally stored (entire) dataset and return reconstruction for the sequence being passed to this function
   alglib.SSAAnalyzeSequence(ssa_model,x,x.Size(),trend,noise);
//--- print result
   PrintVector(trend);
//--- output:   [0.381548,0.558290,0.781016,1.079470,1.504191,2.010505]
//--- EXPECTED: [0.3815,0.5582,0.7810,1.0794,1.5041,2.0105]
   return 0;
  }

//+------------------------------------------------------------------+
//| ssa_d_forecast                                                   |
//+------------------------------------------------------------------+
//| Here we demonstrate SSA forecasting on some toy problem with     |
//| clearly visible linear trend and small amount of noise.          |
//+------------------------------------------------------------------+
int ssa_d_forecast(void)
  {
//--- ALGLIB wrapper
   CAlglib alglib;
//--- model
   CSSAModel ssa_model;
//--- prepare input data
   double input_data[] = {0.05,0.96,2.04,3.11,3.97,5.03,5.98,7.02,8.02};
   CRowDouble x=input_data;
//--- first, we create SSA model, set its properties and add dataset.
//--- we use window with width=3 and configure model to use direct SSA algorithm - one which runs exact O(N*W^2) analysis-to extract two top singular vectors
//--- NOTE: SSA model may store and analyze more than one sequence (say, different sequences may correspond to data collected from different devices)
//--- create SSA model
   alglib.SSACreate(ssa_model);
//--- set window width for SSA model
   alglib.SSASetWindow(ssa_model,3);
//--- set window width for SSA model
   alglib.SSAAddSequence(ssa_model,x);
//--- set SSA algorithm to "direct top-K" algorithm
   alglib.SSASetAlgoTopKDirect(ssa_model,2);
//--- now we begin analysis. Internally SSA model stores everything it needs:
//--- data, settings, solvers and so on. Right after first call to analysis-related function it will analyze dataset, build basis and perform analysis.
//--- subsequent calls to analysis functions will reuse previously computed basis, unless you invalidate it by changing model settings (or dataset).
//--- in this example we show how to use ssaforecastlast() function, which predicts changed in the last sequence of the dataset.
//--- if you want to perform prediction for some other sequence, use alglib.SSAForecastSequence().
//--- trend
   CRowDouble trend;
   alglib.SSAForecastLast(ssa_model,3,trend);
//--- print result
   PrintVector(trend);
//--- output:   [9.000587,9.932294,10.805125]
//--- EXPECTED: [9.0005,9.9322,10.8051]
//--- well, we expected it to be [9,10,11]. There exists some difference, which can be explained by the artificial noise in the dataset.
   return 0;
  }
//+------------------------------------------------------------------+
//| ssa_d_realtime                                                   |
//+------------------------------------------------------------------+
//| Suppose that you have a constant stream of incoming data, and    |
//| you want to regularly perform singular spectral analysis         |
//| of this stream.                                                  |
//|                                                                  |
//| One full run of direct algorithm costs O(N*Width^2) operations,  |
//| so the more points you have, the more it costs to rebuild basis  |
//| from scratch.                                                    |
//|                                                                  |
//| Luckily we have incremental SSA algorithm which can perform      |
//| quick updates of already computed basis in O(K*Width^2) ops,     |
//| where K is a number of singular vectors extracted. Usually it    |
//| is orders of magnitude faster than full update of the basis.     |
//|                                                                  |
//| In this example we start from some initial dataset x0. Then we   |
//| start appending elements one by one to the end of the last       |
//| sequence                                                         |
//|                                                                  |
//| NOTE: direct algorithm also supports incremental updates, but    |
//|       with O(Width^3) cost. Typically K<<Width, so specialized   |
//|       incremental algorithm is still faster.                     |
//+------------------------------------------------------------------+
int ssa_d_realtime(void)
  {
//--- ALGLIB wrapper
   CAlglib alglib;
//--- model
   CSSAModel ssa_model1;
//---
   CMatrixDouble a1;
   CRowDouble sv1;
   int w,k;
//--- prepare input data
   double input_data[]= {0.009,0.976,1.999,2.984,3.977,5.002};
   CRowDouble x0=input_data;
//--- create SSA model
   alglib.SSACreate(ssa_model1);
//--- set window width for SSA model
   alglib.SSASetWindow(ssa_model1,3);
//--- adds data sequence to SSA model
   alglib.SSAAddSequence(ssa_model1,x0);
//--- set algorithm to the real-time version of top-K, K=2
   alglib.SSASetAlgoTopKRealtime(ssa_model1,2);
//--- one more interesting feature of the incremental algorithm is "power-up" cycle.
//--- even with incremental algorithm initial basis calculation costs O(N*Width^2) ops.
//--- if such startup cost is too high for your real-time app, then you may divide initial basis calculation
//--- across several model updates. It results in better latency at the price of somewhat lesser precision during first few updates.
   alglib.SSASetPowerUpLength(ssa_model1,3);
//--- now, after we prepared everything, start to add incoming points one by one;
//--- in the real life, of course, we will perform some work between subsequent update (analyze something, predict, and so on).
//--- after each append we perform one iteration of the real-time solver. Usually
//--- one iteration is more than enough to update basis. If you have REALLY tight performance constraints,
//--- you may specify fractional amount of iterations, which means that iteration is performed with required probability.
   double updateits = 1.0;
//--- append single point to last data sequence stored in the SSA model and update model in the incremental manner
   alglib.SSAAppendPointAndUpdate(ssa_model1,5.951,updateits);
//--- execute SSA on internally stored dataset and get basis found by current method
   alglib.SSAGetBasis(ssa_model1,a1,sv1,w,k);
//--- append single point to last data sequence
   alglib.SSAAppendPointAndUpdate(ssa_model1,7.074,updateits);
//--- execute SSA
   alglib.SSAGetBasis(ssa_model1,a1,sv1,w,k);
//--- append single point to last data sequence
   alglib.SSAAppendPointAndUpdate(ssa_model1,7.925,updateits);
//--- execute SSA
   alglib.SSAGetBasis(ssa_model1,a1,sv1,w,k);
//--- append single point to last data sequence
   alglib.SSAAppendPointAndUpdate(ssa_model1,8.992,updateits);
//--- execute SSA
   alglib.SSAGetBasis(ssa_model1,a1,sv1,w,k);
//--- append single point to last data sequence
   alglib.SSAAppendPointAndUpdate(ssa_model1,9.942,updateits);
//--- execute SSA
   alglib.SSAGetBasis(ssa_model1,a1,sv1,w,k);
//--- append single point to last data sequence
   alglib.SSAAppendPointAndUpdate(ssa_model1,11.051,updateits);
//--- execute SSA
   alglib.SSAGetBasis(ssa_model1,a1,sv1,w,k);
//--- append single point to last data sequence
   alglib.SSAAppendPointAndUpdate(ssa_model1,11.965,updateits);
//--- execute SSA
   alglib.SSAGetBasis(ssa_model1,a1,sv1,w,k);
//--- append single point to last data sequence
   alglib.SSAAppendPointAndUpdate(ssa_model1,13.047,updateits);
//--- execute SSA
   alglib.SSAGetBasis(ssa_model1,a1,sv1,w,k);
//--- append single point to last data sequence
   alglib.SSAAppendPointAndUpdate(ssa_model1,13.970,updateits);
//--- execute SSA
   alglib.SSAGetBasis(ssa_model1,a1,sv1,w,k);
//--- ok, we have our basis in a1[] and singular values at sv1[]. But is it good enough? Let's print it.
   PrintMatrix(a1);
//--- output:   [[0.510607,0.753611],[0.575201,0.058445],[0.639081,-0.654717]]
//--- EXPECTED: [[0.510607,0.753611],[0.575201,0.058445],[0.639081,-0.654717]]
//--- ok, two vectors with 3 components each. but how to understand that is it really good basis? let's compare it with direct SSA algorithm on the entire sequence.
   CSSAModel ssa_model2;
   CMatrixDouble a2;
   CRowDouble sv2;
//--- input data
   double input_data2[]= {0.009,0.976,1.999,2.984,3.977,5.002,5.951,7.074,7.925,8.992,9.942,11.051,11.965,13.047,13.970};
   CRowDouble x2=input_data2;
//--- create SSA model
   alglib.SSACreate(ssa_model2);
//--- set window width for SSA model
   alglib.SSASetWindow(ssa_model2,3);
//--- add data sequence to SSA model
   alglib.SSAAddSequence(ssa_model2,x2);
//--- set SSA algorithm to "direct top-K" algorithm
   alglib.SSASetAlgoTopKDirect(ssa_model2,2);
//--- execute SSA on internally stored dataset and get basis found by current method
   alglib.SSAGetBasis(ssa_model2,a2,sv2,w,k);
//--- it is exactly the same as one calculated with incremental approach!
   PrintMatrix(a2);
//--- output:   [[0.510607,0.753611],[0.575201,0.058445],[0.639081,-0.654717]]
//--- EXPECTED: [[0.510607,0.753611],[0.575201,0.058445],[0.639081,-0.654717]]
   return 0;
  }
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- the very simple example of trend/noise separation
   ssa_d_basic();
//--- forecasting with SSA
   ssa_d_forecast();
//--- real-time analysis of constantly arriving data
   ssa_d_realtime();
  }
//+------------------------------------------------------------------+


결론

ALGLIB은 금융 시장의 데이터를 분석하는 강력한 도구이며 다국어 지원, 크로스 플랫폼 특성, 풍부한 기능 및 오픈 소스 덕분에 재무 분석 및 모델링 분야의 연구자와 개발자에게 매력적인 선택이 될 수 있습니다. 신뢰할 수 있는 데이터 분석 도구에 대한 요구는 계속되고 있으며 ALGLIB은 지속적인 개발과 개선을 지원함으로써 이러한 요구를 성공적으로 해결하고 있습니다.

MetaTrader 5 플랫폼 개발자들은 트레이더에게 최고의 솔루션을 제공합니다:

  • 속도 면에서 C++만큼 뛰어난 MQL5 언어를 지원합니다;
  • SQLite 데이터베이스의 기본 제공 처리, OpenCL을 사용하여 계산을 수행하는 기능, DirectX 지원, ONNX 모델 사용 및 Python과의 통합;
  • 퍼지 논리, 통계 및 업데이트된 ALGLIB 버전을 포함한 수학 라이브러리.

MetaQuotes 소프트웨어 사를 통해 러시아어가 번역됨.
원본 기고글: https://www.mql5.com/ru/articles/13289

파일 첨부됨 |
SSA_Test.mq5 (26.56 KB)
새로운 기능: MQL5의 커스텀 인디케이터 새로운 기능: MQL5의 커스텀 인디케이터
MetaTrader5와 MQL5의 새로운 기능 전체를 나열하지는 않겠습니다. 종류도 많은 데다가, 별도의 설명이 필요한 기능들도 있거든요. 객체 지향 프로그래밍을 이용한 코드 작성법 또한 다음에 알아보도록 하겠습니다. 다른 기능들과 함께 설명하기에는 조금 어려운 이야기일 수 있으니까요. 이 글에서는 인디케이터와 인디케이터의 구조, 드로잉 타입과 프로그래밍 디테일을 MQL4와 비교해 볼게요. 초보자 분들께 많은 도움이 되면 좋겠고 기존에 사용하시던 개발자 분들도 뭔가 새로운 걸 얻어 가실 수 있길 바랍니다.
MQL4 및 MQL5 개발 프레임워크 내 OpenAI의 ChatGPT 기능 MQL4 및 MQL5 개발 프레임워크 내 OpenAI의 ChatGPT 기능
이 글에서는 Expert Advisors, 지표 및 스크립트를 개발하는 데 드는 시간과 노동 강도를 줄이는 측면에서 OpenAI의 ChatGPT를 살펴보고 그 기능에 대해 알아보겠습니다. 이제부터 ChatGPT를 MQL4 및 MQL5에서 프로그래밍에 올바르게 사용하는 방법을 보여 드리겠습니다.
새 MetaTrader 와 MQL5를 소개해드립니다 새 MetaTrader 와 MQL5를 소개해드립니다
본 문서는 MetaTrader5의 간략 리뷰입니다. 짧은 시간 내에 시스템의 모든 세부 사항을 안내해드리기는 어렵습니다 - 테스트는 2009.09.09에 시작되었습니다. 이는 상징적인 일자로, 전 이것이 행운의 숫자가 될거라 믿어 의심치않습니다. 제가 새 MetaTrader 5 터미널과 MQL5 베타버전을 받은지 며칠이 지났습니다. 아직 모든 기능을 사용해본 것은 아니지만, 벌써부터 감명깊네요.
트레이딩을 위한 조합론과 확률 이론(3부): 첫 번째 수학적 모델 트레이딩을 위한 조합론과 확률 이론(3부): 첫 번째 수학적 모델
앞서 살펴본 주제에 대해 논리적으로 연속적인 내용을 다루자면 그것은 아마도 트레이딩 작업을 위한 다기능 수학적 모델의 개발일 것입니다. 이 글에서 저는 프랙탈을 설명하는 최초의 수학적 모델의 개발과 관련된 전체의 과정을 처음부터 설명하겠습니다. 이 모델은 중요한 빌딩 블록이 되어야 하며 다 기능적이고 보편적이어야 합니다. 그리고 모델은 우리의 아이디어를 더욱 발전시키기 위한 이론적 기반을 구축할 것입니다.