<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>参数 on 格物堂</title><link>https://gewutang.cn/tags/%E5%8F%82%E6%95%B0/</link><description>Recent content in 参数 on 格物堂</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><lastBuildDate>Thu, 23 Jun 2011 00:00:00 +0000</lastBuildDate><atom:link href="https://gewutang.cn/tags/%E5%8F%82%E6%95%B0/index.xml" rel="self" type="application/rss+xml"/><item><title>用四个参数拟合大象</title><link>https://gewutang.cn/2011/06/23/use-four-parameters-to-fit-an-elephant/</link><pubDate>Thu, 23 Jun 2011 00:00:00 +0000</pubDate><guid>https://gewutang.cn/2011/06/23/use-four-parameters-to-fit-an-elephant/</guid><description>&lt;p&gt;冯·诺依曼说过一句话，&lt;/p&gt;&#10;&#10; &lt;blockquote&gt;&#10; &lt;p&gt;With four parameters I can fit an elephant, and with five I can make him wiggle his trunk.&lt;/p&gt;&#10;&#10; &lt;/blockquote&gt;&#10;&lt;p&gt;冯·诺依曼说这句话的时候，当然是一种隐喻。他的大致意思是说，当一个模型能够完美拟合一个数据集的时候，不要沾沾自喜或者得意到脱掉下巴。因为之所以出现这种情况很可能是因为模型的参数太多，而不是模型的形式很好。如果给模型足够多的参数，我们实际上可以完美的拟合任何数据集。&lt;/p&gt;&#10;&lt;p&gt;虽然用四个参数来拟合大象并非是冯·诺依曼的本意，可是打他说出来这句话起，就有很多人前赴后继地研究如何用四个参数来真的拟合出来一头大象。后来，Jurgen Mayer, Khaled Khairy, and Jonathon Howard在论文“Drawing an elephant with four complex parameters”当真实现了这句话。&lt;/p&gt;&#10;&lt;p&gt;绘制大象的R代码如下：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code class="language-r"&gt;p1=50-30i&#10;p2=18+8i&#10;p3=12-10i&#10;p4=-14-60i&#10;p5=40+20i&#10;&#10;fourier=function(tt,CC){&#10;f=numeric(length(tt));&#10;A=Re(CC);&#10;B=Im(CC);&#10;k=1:length(CC);&#10;for(i in 1:length(tt)){&#10;co=cos(tt[i]*k)&#10;si=sin(tt[i]*k)&#10;f[i]=sum(A*co+B*si)&#10;f&#10;}&#10;f&#10;}&#10;&#10;elephant=function(tt,p1,p2,p3,p4,p5){&#10;n=6&#10;Cx=complex(n);&#10;Cy=complex(n);&#10;Cx[1]=Re(p1)*1i&#10;Cx[2]=Re(p2)*1i&#10;Cx[3]=Re(p3)&#10;Cx[5]=Re(p4)&#10;Cy[1]=Im(p4)+Im(p1)*1i&#10;Cy[2]=Im(p2)*1i&#10;Cy[3]=Im(p3)*1i&#10;&#10;x=fourier(tt,Cx)&#10;y=fourier(tt,Cy)&#10;res=cbind(y,-x)&#10;res&#10;}&#10;&#10;tt=seq(from=0,to=2*pi,length=100)&#10;el=elephant(tt,p1,p2,p3,p4,p5)&#10;&#10;plot(el,type=&amp;quot;l&amp;quot;,col=&amp;quot;red&amp;quot;,ylab=&amp;quot;&amp;quot;,xlab=&amp;quot;&amp;quot;,lwd=2)&#10;points(Im(p5),Im(p5),pch=20,col=&amp;quot;red&amp;quot;) &#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;img src="https://gewutang.cn/2011/06/23/use-four-parameters-to-fit-an-elephant/index_files/figure-html/unnamed-chunk-1-1.png" width="672" /&gt;&#10;</description></item></channel></rss>