Software Implementation of Algorithms for Calculating Pearson, Spearman and Kendall Correlations in C#

Анотація
Formulation of the problem. In scientific research in sociology, education, physics, chemistry and other sciences, methods of correlation analysis are used. Correlation coefficients are used to determine the existence of a relationship between two or more data samples. The use of correlation coefficients allows the researcher to determine whether there is a relationship between two data sets and the nature of that relationship: strong or weak, direct or inverse. Thanks to correlation methods, the researcher has an effective tool for confirming or disproving a hypothesis. Information technology tools play an important role in the application of correlation analysis in practice. These tools enable reducing the processing time for scientific research results by several times. Software tools used in correlation analysis vary widely, from MS Excel spreadsheets to STATISTICA and the R programming language. A common drawback of these IT tools is that the researcher using them must have a certain level of mathematical training (STATISTICA), programming skills (R), or manual data entry skills (MS Excel). There is a discrepancy between the capabilities of ICT for correlation analysis and how they are currently used. Materials and methods. During the research, we used the following methods: analysis and synthesis of scientific literature on correlation analysis, algorithm theory, object-oriented programming, and the foundations of scientific research; comparative analysis of algorithms for calculating Pearson, Spearman, and Kendall correlation coefficients; algorithmic method for constructing correlation calculation algorithms; object-oriented programming methods for software development of developed algorithms; correlation methods; computational complexity testing; accuracy testing; exception testing (handling missing values, different sample sizes); numerical stability testing. Results. Algorithms for calculating Pearson, Spearman, and Kendall correlations have been implemented in the C# language. During development, component-oriented and object-oriented approaches in programming were used. Algorithms for calculating Pearson, Spearman, and Kendall correlations are presented in the C# language in the form of a program library in DLL format, which consists of 5 classes. Classes and methods for calculating Pearson, Spearman, and Kendall correlations have been developed. The objective novelty is the software implementation of the algorithm for calculating Kendall correlations for the .NET platform. To calculate the specified correlation coefficients, the CorrAnalyzer application has been developed, which connects to the program library created. The developed library and application are recommended for use in pedagogical, psychological, and sociological research to determine the relationship between the two samples. Conclusions. Correlation methods are used to determine the relationship between two samples. The most commonly used are Pearson, Spearman, and Kendall correlations. The Pearson, Spearman, and Kendall correlation coefficients differ in their principles and calculation algorithms. Based on testing results for accuracy, computational complexity, and exceptions, the suitability of the developed methods for processing experimental results was determined. To make the software library a powerful tool for determining relationships between samples, all three of the above correlation methods are implemented in it. The library for calculating correlation is implemented as a component (DLL) that is integrated into the CorrAnalyzer application, written in C#. The CorrAnalyzer application is designed to determine the relationship between small samples (up to 1000 values). In the future, it is advisable to supplement the developed software library with classes for calculating the Matthews correlation and concordance.
Формулювання проблеми. У наукових дослідженнях з соціології, освіти, фізики, хімії та інших наук використовуються методи кореляційного аналізу. За допомогою коефіцієнтів кореляції визначають існування зв’язку між двома і більше вибірками даних.Використання коефіцієнтів кореляції надає можливість досліднику з’ясувати, чи існує зв’язок між двома наборами даних, а також характер цього зв’язку: сильний чи слабкий, прямий чи обернений. Завдяки методам кореляції дослідник має дієвий інструмент для підтвердження чи спростування гіпотези.Важливе місце у застосуванні кореляційного аналізу на практиці відіграють засоби інформаційних технологій. Ці засоби надають можливість зменшити час обробки результатів наукових досліджень у кілька разів. Програмні засоби, які використовуються під час кореляційного аналізу, варіюються у широкому спектрі: до них належать і електронні таблиці MS Excel, і математичний пакет STATISTICA, і мова програмування R. Спільним недолікомзазначених засобів ІТ є те, що дослідник, який їх використовує, повинен мати певний рівень математичної підготовки (STATISTICA), або навички програмування (мова R), або виконувати введення даних вручну (MS Excel). Виникає суперечність між можливостями ІКТ для кореляційного аналізу і тим, як вони застосовуються зараз.Матеріали і методи. Під час виконання дослідження ми використали такі методи: аналіз і синтез наукової літератури з кореляційного аналізу, теорії алгоритмів, об’єктно-орієнтованого програмування, основ наукових досліджень; порівняльний аналіз алгоритмів розрахунку коефіцієнтів кореляції Пірсона, Спірмена, Кендалла; алгоритмічний метод для побудови алгоритмів розрахунку кореляції; методи об'єктно-орієнтованого програмування для програмної розроблених алгоритмів; методи кореляції; тестуванння обчислювальної складності алгоритмів; тестування точності; тестування виняткових ситуацій (пропуск значень, різні розміри вибірок), тестування стабільності.Результати. Реалізовано мовою C# алгоритми обчислення кореляції Пірсона, Спірмена і Кендалла. Під час розробки використано компонентно-орієнтований і об'єктно-орієнтований підходи у програмуванні. Алгоритми обчислення кореляції Пірсона, Спірмена і Кендалла представлені мовою C# у вигляді програмної бібліотеки у форматі DLL, яка складається з 5 класів. Розроблені класи і методи для обчислення кореляції Пірсона, Спірмена і Кендалла. Об’єктивною новизною є програмна реалізація алгоритму обчислення кореляції Кендалла для платформи .NET. Для розрахунку вказаних коефіцієнтів кореляції розроблено додаток CorrAnalyzer, до якого підключено створену програмну бібліотеку. Розроблені бібліотеку і додаток доцільно використовувати у педагогічних, психологічних, соціологічних дослідженнях для визначення зв’язку між двома вибірками.Висновки. Методи кореляції застосовуються для визначення зв’язку між двома вибірками. Найбільш часто використовуються кореляції Пірсона, Спірмена і Кендалла. Коефіцієнти кореляції Пірсона, Спірмена і Кендалла відрізняються за принципом і алгоритмом розрахунку. На основі результатів тестування точності, обчислювальної складності і винятків визначено придатність розроблених методів для застосування під час обробки результатів експерименту. Для того, щоб створювана програмна бібліотека являла собою потужний інструмент для визначення зв’язку між вибірками, в ній реалізовані всі три методи кореляції. Бібліотеку для розрахунку кореляції реалізовано у вигляді компонента (файл DLL), який інтегровано у додаток CorrAnalyzer, написаний мовою C#. Додаток CorrAnalyzer призначений для визначення зв’язку між невеликими вибірками (до 1000 значень). У перспективі розроблену програмну бібліотеку доцільно доповнити класами для розрахунку кореляції Метьюза і конкордації.
Опис
Ключові слова
correlation, algorithm, Pearson, Spearman, Kendall, component-oriented approach, software library, кореляція, алгоритм, Пірсон, Спірмен, Кендалл, компонентно-орієнтований підхід, прогармна бібліотека
Бібліографічний опис
Software Implementation of Algorithms for Calculating Pearson, Spearman and Kendall Correlations in C# [Техt] / V. Bazurin, S. Bazurina, S. Kolesnyk, V. Kolesnyk, N. Dulenko // Фізико-математична освіта : науковий журнал / Міністерство освіти і науки України, Сумський державний педагогічний університет імені А. С. Макаренка, Фізико-математичний факультет ; редкол.: О. Семеніхіна, М. Друшляк, Francis Kwadwo Awuah та ін. – Суми : СумДПУ імені А. С. Макаренка, 2026. – Вип. 2 (41). – С. 06–17. – DOI: 10.31110/fmo2026.v41i2-01