/usr/share/hyphy/ChartAddIns/Linear Fit is in hyphy-common 2.2.7+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | if (NON_EMPTY_SELECTION)
{
data_rows = Columns (SELECTED_CHART_ROWS);
if (data_rows % 2 == 0)
{
temp = -1;
data_columns = -1;
for (count = 0; count<data_rows; count = count+1)
{
temp2 = SELECTED_CHART_COLS[count];
if (temp<0)
{
temp = temp2;
}
else
{
if (temp!=temp2)
{
if (data_columns<0)
{
data_columns = temp2;
}
else
{
if (temp2!=data_columns)
{
break;
}
}
}
}
}
if ((count == data_rows)&&(data_columns>=0)&&(temp>=0))
{
for (count = 0; count < data_rows; count = count+2)
{
if (SELECTED_CHART_ROWS[count]!=SELECTED_CHART_ROWS[count+1])
{
break;
}
}
if (count==data_rows)
{
SELECTED_CHART_ROWS = {2,data_rows/2};
for (count = 0; count < data_rows; count = count+2)
{
SELECTED_CHART_ROWS[0][count/2]=SELECTED_CHART_DATA[count];
SELECTED_CHART_ROWS[1][count/2]=SELECTED_CHART_DATA[count+1];
}
SELECTED_CHART_DATA = SELECTED_CHART_ROWS;
LoadFunctionLibrary ("ProbabilityDistributions");
lfit = linearFit (Transpose(SELECTED_CHART_DATA));
fprintf (stdout, "\n\nCorrelation coefficient:",lfit["Correlation"],"\n");
fprintf (stdout, "\nLinear fit :\n\t y = ",lfit["Intercept"]," + ", lfit["Slope"], " * x\n");
fprintf (stdout, "\nB = ",lfit["Slope"], " +/- ", Sqrt (lfit["Var(Slope)"]),"\nA = ",lfit["Intercept"], " +/- ", Sqrt (lfit["Var(Intercept)"]),"\n");
return;
}
}
}
fprintf (stdout, "Please select two columns with independent values (1st column) and dependent values (2nd columns).\n");
}
else
{
NON_EMPTY_SELECTION = -1;
}
|