Algorithm 我可以对该算法进行哪些更改以绘制对数图最佳拟合曲线?
我在这里使用了一种算法:绘制一条最佳拟合线,如下所示:Algorithm 我可以对该算法进行哪些更改以绘制对数图最佳拟合曲线?,algorithm,qt,logarithm,graph-drawing,best-fit-curve,Algorithm,Qt,Logarithm,Graph Drawing,Best Fit Curve,我在这里使用了一种算法:绘制一条最佳拟合线,如下所示: int pointCount = 0; //The number of readings in the graph double SumX = 0; //Sum of all the X values double SumY = 0; //Sum of all the Y values double SumX2 = 0; //Sum of all the squares of the X values dou
int pointCount = 0; //The number of readings in the graph
double SumX = 0; //Sum of all the X values
double SumY = 0; //Sum of all the Y values
double SumX2 = 0; //Sum of all the squares of the X values
double SumXY = 0; //Sum of all the products X*Y for all the points
double XMean = 0; //Mean of the X values
double YMean = 0; //Mean of the Y values
double Gradient = 0; //The gradient of the graph
double YIntercept = 0; //The y-intercept of the graph
for (int q=0; q<29;q++)
{
if (GraphReadings[q*2+2] != 0)
{
pointCount = pointCount + 1;
SumX=SumX + q;
SumY=SumY + GraphReadings[q*2+2];
SumX2=SumX2 + (q*q);
SumXY=SumXY + (q*GraphReadings[q*2+2]);
}
}
XMean = SumX / pointCount;
YMean = SumY / pointCount;
Gradient = (SumXY - SumX * YMean) / (SumX2 - SumX * XMean);
YIntercept = YMean - Gradient * XMean;
for (int k = 0; k<141; k++)
{
x2[k]=k;
y2[k]=Gradient * k + YIntercept;
}
int pointCount=0//图表中的读数数
双SumX=0//所有X值之和
双SumY=0//所有Y值之和
双SumX2=0//X值的所有平方和
双SumXY=0//所有点的所有乘积X*Y之和
双XMean=0//X值的平均值
双YMean=0//Y值的平均值
双梯度=0//图的梯度
双Y间期=0//图的y截距
对于(int q=0;请询问您最喜欢的“对数回归”搜索引擎。或者阅读这些内容。@Axelkeper这与“逻辑回归”相同吗?否,“逻辑回归”处理的是将项目分配给a(通常较小)的分类变量集合或类别的数量。对于您的情况,对数回归看起来像是选择的方法,因为它将对数数据转换为线性数据。