<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>またアホなこと言うてるブログ</title>
<link>https://ameblo.jp/butanikoban/</link>
<atom:link href="https://rssblog.ameba.jp/butanikoban/rss20.xml" rel="self" type="application/rss+xml" />
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
<description>ブログの説明を入力します。</description>
<language>ja</language>
<item>
<title>正規分布を作る</title>
<description>
<![CDATA[ とある金融機関の入社試験で、正規分布になるように乱数をふるプログラムを作れというものが出たらしい。<br><br>その話を聞いてパッと思いついたものを書いてみた。<br><br>#include <stdio.h><br>#include <stdlib.h><br><br>int main(void){<br>int height,h;//高さ<br>int x;//ｘ軸上の位置<br>int r;//乱数<br>int N=10000;//降らす点の個数<br>int ground[1000]={0};//地面<br>int i;<br>FILE*fp;<br><br>printf("点を降らせる高さを入力:\n");<br>scanf("%d",&amp;h);<br><br>for(i=0;i<n;i++){<br />x=500;<br>height=h;<br>while(height&gt;0){<br>r=rand()%3;<br>if(r==0){<br>height--;<br>}<br>if(r==1){<br>x++;<br>}<br>if(r==2){<br>x--;<br>}<br>}<br>if(x&lt;0 || x&gt;1000){<br>puts("点が定義域の外に出た");<br>break;<br>}<br>ground[x]++;<br>}<br>fp=fopen("normaldistribution.dat","w");<br>for(i=0;i&lt;1000;i++){<br>fprintf(fp,"%d %d\n",i,ground[i]);<br>}<br>fclose(fp);<br><br>return 0;<br>}<br><br><a href="http://stat.ameba.jp/user_images/9e/90/10054180144.gif" target="_blank"><img src="https://stat.ameba.jp/user_images/9e/90/10054180144_s.gif" alt="" width="220" height="147" border="0"></a><br><br>見た目にはいい感じ。<br><br>要は、ある高さから点をたくさん降らせて、それが地面に積もる時の積もり方を正規分布とみてる。</stdlib.h></stdio.h>
]]>
</description>
<link>https://ameblo.jp/butanikoban/entry-10081189327.html</link>
<pubDate>Wed, 19 Mar 2008 16:32:38 +0900</pubDate>
</item>
</channel>
</rss>
