Хорошо хранить эти данные в MySQL, но вы можете обрабатывать данные с языка, который имеет доступ к базе данных.Псевдокод:
variables = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I' ];
for X in $variables do
for Y in $variables do
query = 'SELECT
@'+$X+$Y+' := COUNT(score) AS '+$X+$Y+',
@mean'+$X+' := AVG(age) AS "X mean",
@sum'+$X+' := SUM(age) AS "X sum",
@sum'+$X+$X+' := SUM(age*age) "X sum of squares",
@mean'+$Y+' := AVG(score) AS "Y mean",
@sum'+$Y+' := SUM(score) AS "Y sum",
@sum'+$Y+$Y+' := SUM(score*score) "Y sum of square",
@sum'+$X+$Y+' := SUM(age*score) AS "X*Y sum"';
db_execute(query);
done
done
но почему бы не сохранить результаты в таблице?Более подходит для базы данных.
for X in $variables do
for Y in $variables do
query = 'INSERT INTO regression SELECT FROM measurements
"'+$X+'" AS X
"'+$Y+'" AS Y
score AS valX
age AS valY
COUNT(score) AS N,
AVG(age) AS meanX,
SUM(age) AS sumX,
SUM(age*age) squareX,
AVG(score) AS meanY,
SUM(score) AS sumY,
SUM(score*score) squareY,
SUM(age*score) AS sumXY';
db_execute(query);
done
done
Поместите отдельный индекс в столбцы X и Y.