anchor.diff:          }.
   
           
  -stddev_variance( #stream_stddev{ n = 1 } )          -> 0.0;
  +stddev_variance( #stream_stddev{ n = N
  +                               , ddof = Ddof } )
  +        when N =< Ddof ->
  +    0.0;
   stddev_variance( #stream_stddev{ n = N
                                  , m2 = M2
                                  , ddof = Ddof } )    ->
  
positive.code:     , mean      = 0.0       :: float()
      , m2        = 0.0       :: float()
      , delta     = 0.0       :: float()
      }).
  
  
  
negative.code: stddev_values( #stream_stddev{ mean = Mean } = X )  ->
      { Mean, math:sqrt( stddev_variance(X) ) }.
  
      
  stddev_samples( #stream_stddev{ n = N } ) -> N.
  
  
  %%%%% ------------------------------------------------------- %%%%%
  
  
  -spec sample_new( pos_integer() ) -> #stream_sample{}.
  
  sample_new(N) ->
      #stream_sample{ size = N }.
      
  
  sample_update( X
               , #stream_sample{ size = N
                               , count = Cnt
                               , data = Data } = State)
          when Cnt < N  ->
      State#stream_sample{ count = Cnt + 1
                         , data = erlang:append_element(Data, X) };
                         
                         
  sample_update( X
               , #stream_sample{ size = N
                               , count = Cnt
                               , data = Data } = State) ->
      R = rand:uniform(Cnt + 1),
      NewData =   case R =< N of
                      true    -> erlang:setelement(R, Data, X)
                  ;   false   -> Data
                  end,
      State#stream_sample{ count = Cnt + 1
                         , data = NewData }.
  
                         
  sample_values( #stream_sample{ data = Data } ) ->                       
      erlang:tuple_to_list(Data).
  
                         
  %%%%% ------------------------------------------------------- %%%%%
  
  