中心極限定理を確認する
0〜1の数字をランダムに生成するプログラムを用いて, 擬似正規分布を生成しよう
Random[ ]:  0〜1の数字をランダムに生成する関数

準備

サブルーチンの読み込み     (* おまじない *)

<< Graphics`Graphics`  
<< Statistics`NormalDistribution`
<< Statistics`DataManipulation`        
<< Statistics`DescriptiveStatistics`

正規分布の密度関数

fNormal[x_, m_, s_] := 
          1/Sqrt[2  Pi s^2] Exp[-((x - m)/s)^2/2];   
fig = 
          Plot[ fNormal[x, 0, 1], {x, -6, 6}, PlotStyle -> Hue[1]];

データの個数などを決める

ndata = 10000;         
div = 0.1;                    
midpoints = Table[i, {i, -6, 6, div}];

Mathematicaの正規分布関数NormalDistribution[μ,σ]による正規分布の生成

data = 
        RandomArray[NormalDistribution[0, 1], 
          ndata];
Print["\:30c7-\:30bf\:306e\:30b0\:30e9\:30d5(\:6a2a\:8ef8\
\:306b\:30c7-\:30bf\:306e\:756a\:53f7, \:7e26\:8ef8\:306b\:30c7-\:30bf\:306e\
\:5024\:3092\:793a\:3057\:305f)"]; ListPlot[data]   ;  
freq = BinCounts[data, {-6, 6, div}]/ndata/div;               
Print["\:30d2\:30b9\:30c8\:30b0\:30e9\:30e0"];
fig1 = 
        Histogram[freq, FrequencyData -> True, 
          HistogramCategories -> 
            midpoints];
Print["\:6b63\:898f\
\:5206\:5e03\:66f2\:7dda"];
fig2 = 
        Plot[ fNormal[x, 0, Sqrt[1]], {x, -6, 6}, 
          PlotStyle -> {RGBColor[0, 1, 
                0]}];
Print["\:30d2\:30b9\:30c8\
\:30b0\:30e9\:30e0\:3068\:6b63\:898f\:5206\:5e03\:66f2\:7dda"];
Show[fig1, fig2];
me = 
      Mean[data]; 
    va = Variance[
        data];
Print["\:5e73\:5747 = ", 
      me, "   (\:7406\:8ad6\:5024 ", 0, " \:3068\:306e\:5dee = ", 
      me - 0, " )"]
Print["\:5206\:6563 = \
", va, "   (\:7406\:8ad6\:5024 ", 1, " \:3068\:306e\:5dee = ", 
      va - 1, " )"]

Random[ ] 関数を利用した疑似正規分布の生成 1  
確率密度関数 f(x) = 1 (0 < x <1) に従うデータから疑似正規分布を作る

Random[ ] 関数での確率密度関数は f(x) =1 (0<x<1) だ!! これを確認しよう!!

data = Table[Random[], {ndata}];
Print["\:30c7-\:30bf\:306e\:30b0\:30e9\:30d5(\:6a2a\:8ef8\
\:306b\:30c7-\:30bf\:306e\:756a\:53f7, \:7e26\:8ef8\:306b\:30c7-\:30bf\:306e\
\:5024\:3092\:793a\:3057\:305f)"]; ListPlot[data]     
Print["\:3053\:308c\:304c Random[] \
\:95a2\:6570\:306b\:3088\:308b\:4e71\:6570\:306e\:5206\:5e03"];
Histogram[data];
me = 
      Mean[data]; 
    va = Variance[
        data];
Print["\:5e73\:5747 = ", 
      me, "   (\:7406\:8ad6\:5024 ", 1/2, " \:3068\:306e\:5dee = ", 
      me - 1/2, " )"]
Print["\:5206\:6563 = \
", va, "   (\:7406\:8ad6\:5024 ", 1/12, " \:3068\:306e\:5dee = ", 
      va - 1/12, " )"]

Random[ ] 関数によって生成された乱数xiを12個足しあわせたz:
  z=x1+x2+x3+......+x12 - 6
が疑似正規分布になることを確認しよう!!

data = 
        Table[Sum[Random[], {12}] - 6, {ndata}];
Print["\:30c7-\:30bf\:306e\:30b0\:30e9\:30d5(\:6a2a\:8ef8\
\:306b\:30c7-\:30bf\:306e\:756a\:53f7, \:7e26\:8ef8\:306b\:30c7-\:30bf\:306e\
\:5024\:3092\:793a\:3057\:305f)"]; ListPlot[data]     
freq = BinCounts[data, {-6, 6, div}]/ndata/div;               
Print["\:30d2\:30b9\:30c8\:30b0\:30e9\:30e0"];
fig1 = 
        Histogram[freq, FrequencyData -> True, 
          HistogramCategories -> 
            midpoints];
Print["\:6b63\:898f\
\:5206\:5e03\:66f2\:7dda"];
fig2 = 
        Plot[ fNormal[x, 0, Sqrt[1]], {x, -6, 6}, 
          PlotStyle -> {RGBColor[0, 1, 
                0]}];
Print["\:30d2\:30b9\:30c8\
\:30b0\:30e9\:30e0\:3068\:6b63\:898f\:5206\:5e03\:66f2\:7dda"];
Show[fig1, fig2];
me = 
      Mean[data]; va = Variance[data]; 
    Print["\:5e73\:5747 = ", me, "   (\:7406\:8ad6\:5024 ", 
      0, " \:3068\:306e\:5dee = ", 
      me - 0, " )"]
Print["\:5206\:6563 = \
", va, "   (\:7406\:8ad6\:5024 ", 1, " \:3068\:306e\:5dee = ", 
      va - 1/12*12, " )"]

Random[ ] 関数を利用した疑似正規分布の生成 2
確率密度関数 f(x) = 2x (0 < x <1)  に従うデータから疑似正規分布を作る

Random[ ] 関数を用いて, 確率密度関数が 　f(x) = 2x  ( 0 < x < 1 )　となる分布を作り出す!!

data = Table[Random[]^0.5, {ndata}];
Print["\:30c7-\:30bf\:306e\:30b0\:30e9\:30d5(\:6a2a\:8ef8\
\:306b\:30c7-\:30bf\:306e\:756a\:53f7, \:7e26\:8ef8\:306b\:30c7-\:30bf\:306e\
\:5024\:3092\:793a\:3057\:305f)"]; ListPlot[data]   ListPlot[data];     
Histogram[
        data];
me = Mean[data]; 
    va = Variance[data]; 
    Print["\:5e73\:5747 = ", me, "   (\:7406\:8ad6\:5024 ", 
      2/3, " \:3068\:306e\:5dee = ", 
      me - 2/3, " )"]
Print["\:5206\:6563 = \
", va, "   (\:7406\:8ad6\:5024 ", 1/18, " \:3068\:306e\:5dee = ", 
      va - 1/18, " )"]

確率密度関数が 　f(x)=x  ( 0 < x < 1 )　である変数を12個足しあわせた z:
  z=x1+x2+x3+......+x12 -8
が疑似正規分布になることを確認しよう!!

data = 
        Table[Sum[Random[]^ .5, {12}] - 
            2/3*12, {ndata}];
ListPlot[data]     
freq = BinCounts[data, {-6, 6, div}]/ndata/div;               
Print["\:30d2\:30b9\:30c8\:30b0\:30e9\:30e0"];
fig1 = 
        Histogram[freq, FrequencyData -> True, 
          HistogramCategories -> 
            midpoints];
Print["\:6b63\:898f\
\:5206\:5e03\:66f2\:7dda"];
fig2 = 
        Plot[ fNormal[x, 0, Sqrt[2/3]], {x, -6, 6}, 
          PlotStyle -> {RGBColor[0, 1, 
                0]}];
Print["\:30d2\:30b9\:30c8\
\:30b0\:30e9\:30e0\:3068\:6b63\:898f\:5206\:5e03\:66f2\:7dda"];
Show[fig1, fig2];
me = 
      Mean[data]; va = Variance[data]; 
    Print["\:5e73\:5747 = ", me, "   (\:7406\:8ad6\:5024 ", 
      0, " \:3068\:306e\:5dee = ", 
      me - 0, " )"]
Print["\:5206\:6563 = ", va, "   (\:7406\:8ad6\:5024 ", 
        2/3, " \:3068\:306e\:5dee = ", va - 1/18*12, " )"]