anchor.diff:              1 ->
                   rand:uniform_real_s(S0)
           end,
  -    I = trunc(X*100),
  +    I = trunc(X*Buckets),
       A = array:set(I, 1+array:get(I,A0), A0),
  -    basic_uniform_1(N-1, S, Sum+X, A);
  -basic_uniform_1(0, {#{type:=Alg}, _}, Sum, A) ->
  -    Loop = ?LOOP,
  +    basic_uniform_1(N+1, Loop, Buckets, S, Sum+X, A);
  +basic_uniform_1(_N, Loop, Buckets, {#{type:=Alg}, _}, Sum, A) ->
       AverExp = 1.0 / 2,
  -    Buckets = 100,
       Counters = array:to_list(A),
  -    Min = lists:min(Counters),
  -    Max = lists:max(Counters),
  -    basic_verify(Alg, Loop, Sum, AverExp, Buckets, Min, Max).
  -
  -basic_uniform_2(N, S0, Sum, A0) when N > 0 ->
  -    {X,S} = rand:uniform_s(100, S0),
  +    basic_verify(Alg, Loop, Sum, AverExp, Buckets, Counters).
  +
  +basic_uniform_2(Alg, Loop, Buckets) ->
  +    basic_uniform_2(
  +      0, Loop, Buckets, rand:seed_s(Alg), 0,
  +      array:new(Buckets, [ {default, 0}])).
  +%%
  +basic_uniform_2(N, Loop, Buckets, S0, Sum, A0) when N < Loop ->
  +    {X,S} = rand:uniform_s(Buckets, S0),
       A = array:set(X-1, 1+array:get(X-1,A0), A0),
  -    basic_uniform_2(N-1, S, Sum+X, A);
  -basic_uniform_2(0, {#{type:=Alg}, _}, Sum, A) ->
  -    Loop = ?LOOP,
  -    AverExp = ((100 - 1) / 2) + 1,
  -    Buckets = 100,
  +    basic_uniform_2(N+1, Loop, Buckets, S, Sum+X, A);
  +basic_uniform_2(_N, Loop, Buckets, {#{type:=Alg}, _}, Sum, A) ->
  +    AverExp = ((Buckets - 1) / 2) + 1,
       Counters = tl(array:to_list(A)),
  -    Min = lists:min(Counters),
  -    Max = lists:max(Counters),
  -    basic_verify(Alg, Loop, Sum, AverExp, Buckets, Min, Max).
  -
  -basic_bytes(N, S0, Sum0, A0) when N > 0 ->
  -    ByteSize = 100,
  -    {Bin,S} = rand:bytes_s(ByteSize, S0),
  +    basic_verify(Alg, Loop, Sum, AverExp, Buckets, Counters).
  +
  +basic_bytes(Alg, Loop, BytesSize) ->
  +    basic_bytes(
  +      0, Loop, BytesSize, rand:seed_s(Alg), 0,
  +      array:new(256, [{default, 0}])).
  +basic_bytes(N, Loop, BytesSize, S0, Sum0, A0) when N < Loop ->
  +    {Bin,S} = rand:bytes_s(BytesSize, S0),
       {Sum,A} = basic_bytes_incr(Bin, Sum0, A0),
  -    basic_bytes(N-1, S, Sum, A);
  -basic_bytes(0, {#{type:=Alg}, _}, Sum, A) ->
  -    ByteSize = 100,
  -    Loop = (?LOOP * ByteSize) div 100,
  +    basic_bytes(N+1, Loop, BytesSize, S, Sum, A);
  +basic_bytes(_N, Loop, BytesSize, {#{type:=Alg}, _}, Sum, A) ->
       Buckets = 256,
       AverExp = (Buckets - 1) / 2,
       Counters = array:to_list(A),
  -    Min = lists:min(Counters),
  -    Max = lists:max(Counters),
  -    basic_verify(Alg, Loop, Sum, AverExp, Buckets, Min, Max).
  +    basic_verify(Alg, Loop * BytesSize, Sum, AverExp, Buckets, Counters).
   
   basic_bytes_incr(Bin, Sum, A) ->
       basic_bytes_incr(Bin, Sum, A, 0).
  
positive.code: 
  basic_stats_uniform_1(Config) when is_list(Config) ->
      ct:timetrap({minutes,15}), %% valgrind needs a lot of time
      [basic_uniform_1(?LOOP, rand:seed_s(Alg), 0.0, array:new([{default, 0}]))
       || Alg <- [default|algs()]],
      ok.
  
  basic_stats_uniform_2(Config) when is_list(Config) ->
      ct:timetrap({minutes,15}), %% valgrind needs a lot of time
      [basic_uniform_2(?LOOP, rand:seed_s(Alg), 0, array:new([{default, 0}]))
       || Alg <- [default|algs()]],
      ok.
  
  basic_stats_bytes(Config) when is_list(Config) ->
      ct:timetrap({minutes,15}), %% valgrind needs a lot of time
      [basic_bytes(
         ?LOOP div 100, rand:seed_s(Alg), 0, array:new(256, [{default, 0}]))
       || Alg <- [default|algs()]],
      ok.
  
  basic_stats_standard_normal(Config) when is_list(Config) ->
  
negative.code:         [{Mean, Variance} || Mean <- IntendedMeans,
                               Variance <- IntendedVariances],
  
      %% valgrind needs a lot of time
      ct:timetrap({minutes, 6 * length(IntendedMeanVariancePairs)}),
      Result =
          lists:filter(
            fun (R) -> R =/= [] end,
            [begin
                 ct:pal(
                   "Testing normal(~.2f, ~.2f)~n",
                   [float(IntendedMean), float(IntendedVariance)]),
                 lists:filter(
                   fun (R) -> R =/= [] end,
                   [basic_normal_1(?LOOP, IntendedMean, IntendedVariance,
                                   rand:seed_s(Alg), 0, 0)
                    || Alg <- [default|algs()]])
             end || {IntendedMean, IntendedVariance}
                        <- IntendedMeanVariancePairs]),
      Result =:= [] orelse
          ct:fail(Result),
      ok.
  
  basic_uniform_1(Alg, Loop, Buckets) ->
      basic_uniform_1(
        0, Loop, Buckets, rand:seed_s(Alg), 0.0,
        array:new(Buckets, [{default, 0}])).
  %%
  basic_uniform_1(N, Loop, Buckets, S0, Sum, A0) when N < Loop ->
      {X,S} =
          case N band 1 of
              0 ->
  