Zi 字媒體
2017-07-25T20:27:27+00:00
[C/C++ 演算法] 純C 曲線擬合[系統估測](最小平方估測法)
資料來源:http://blog.pfan.cn/weiyutian/41873.html
GITHUB: https://github.com/jash-git/CPP_polynomial_Least_Squares
#include
#include
#include
#define N 5//N個點 輸入的X和Y的筆數
#define T 3 //T次擬合 設定轉移函數的階數
#define W 1//權函數
#define PRECISION 0.00001
//資料來源 http://blog.pfan.cn/weiyutian/41873.html
using namespace std;
float pow_n(float a,int n)//a^n a的n次方
{
int i;
if(n==0)
{
return(1);
}
float res=a;
for(i=1;i=0;i--)
{
temp=argu[i][n];
for(j=n-1;j>i;j--)
{
temp-=argu[i][j]*root[j];
}
root[i]=temp/argu[i][i];
}
}
void get_y(float trans_A[][N],float x_y[][2],float y[],int n)
{
int i,j;
float temp;
for(i=0;i
寫了
5860316篇文章,獲得
23313次喜歡