#include <stdio.h>
#include <stdlib.h>
#include<math.h> //<-------------Should have included
int n;
const int input()
{
printf("insert n:");
scanf("%d",&n);
return n;
}
int Num_amount() //<------------modified
{
int z = n; //<--------take a copy of global n
int amount=0;
while(z>0)
{
amount++;
z=z/10;
}
return amount;
}
int Armstrong() //<------------modified
{
n=input();
int v;
int z=0;
int x=Num_amount();
int i;
while(n>0)
{
v=n%10;
z+=pow(v,x);
n/=10; //<-------modification of global n
}
return z;
}
int main()
{
int z=Armstrong();
printf("%d",z);
}
如何将其反转用于绘图?
我在反转日志换位以消除平稳性方面遇到麻烦。这是移调:
for app in endog:
min_nonzero = series[series[app] > 0].min()[0]
series.loc[series[app] == 0, app] = min_nonzero
series[app + '_log_diff'] = np.log(series[app]).diff()
series = series.replace([np.inf, -np.inf], np.nan).dropna()
因此,我正在为 app_log_diff 建模。我的系列被分为训练组和测试组,并将预测结果重新加载到名为 y 的DF中。
据我了解,.diff()由.cumsum()反转。这给了我日志。 .log()被.exp()反转
在输出时,我认为我应该像这样绘制:
series = u[columns].copy()
endogdiffs = []
for app in endog:
min_nonzero = series[series[app] > 0].min()[0]
series.loc[series[app] == 0, app] = min_nonzero
series[app + '_log'] = np.log(series[app])
series[app + '_log_diff'] = series[app + '_log'].diff()
endogdiffs.append(app + '_log_diff')
series = series.replace([np.inf, -np.inf], np.nan).dropna()
但是-我的初始值(所有这些值,而不仅仅是内生的)都在0-1之间。我的输出值大约是y预测的1-50或60左右。
如何反转转换?
预测部分的详细信息:
for i, app in enumerate(endog):
plt.plot(np.exp(train[app + '_log_diff'].append(y[app + '_log_diff']).cumsum()), color=[(i/10)+0.5, (i/10)+0.5, (i/10)+0.5])
plt.plot(np.exp(train[app + '_log_diff'].append(test[app + '_log_diff']).cumsum()), color=appColors[i])