\(\(\( (*\ 
      Frequenz\ eines\ seltenen\ Allels\ *) \)\(
\)\(\(Clear[n, V, M, h];\)

    \(g = 1000;\)

    \(r = 1.003;\)

    \(kappa := Sign[2*Random[] - 1];\)

    \(n[0] = g;\)

    \(V[0] = 1/\((2  g)\);\)

    \(M[0] = 0;\)

    \(n[j_] := \(n[j] = \((r)\)\ n[j - 1]\);\)

    \(V[j_] := \(V[j] = 
          V[j - 1] + 1/\((4  r\ n[j - 1])\)\ \((1 - M[j - 1])\)\);\)

    \(M[j_] := \(M[j] = 
          n[j - 1]/\((n[j - 1] - 1)\)\ \((V[j - 1] - 
                1/\((2  n[j - 1])\) \((1 + 
                      M[j - 1])\))\)\);\)

    \(h[0] = 1/\((2  g)\);\)

    \(h[j_]\  := \ \(h[j] = 
          h[j - 1] + 
            kappa \((1 - M[j - 1])\)^\((1/2)\) \((8  
                    g\ r\ n[j - 1])\)^\((\(-1\)/2)\)\);\)

    \(f[gen_, pr_] := 
        ListPlot[Table[N[h[j]], {j, 0, gen}], 
          PlotRange -> {\(-pr\), pr}, 
          PlotJoined -> True];\)

    \(f[300, 0.004];\)\)\)\)