title: Calculating variance in prolog
body: <p>i have made a function in Prolog:-</p>
  
  <pre><code>mean(L, M) :-
      sum(L, S),
      length(L, N),
      M is S/N.
  
  sum([],0).
  sum([H|T],Y):-
      sum(T,X),
      Y is X + H.
  
  variance([],0).
  variance([H|T], M, VO):-
      variance(T,M,Y),
      VO is( Y + ((H-M)*(H-M))).
  
  statsList(L, M, V1) :-
      sum(L, S),
      length(L, N),
      M is S/N,
      variance(L, M, VO),
      V1 is V0/N.
  </code></pre>
  
  <p>for some reason when I try to calculate the variance it always replies "false"
  as so: variance([1,2,3],2,VO) or statsList([1,2,3],M,VO)</p>
  
  <p>However if I use this just to test it works:</p>
  
  <pre><code>variance([],0).
  variance([H|T], VO):-
      variance(T,Y),
      VO is( Y + ((H-2)*(H-2))).
  </code></pre>
  
  <p>Can someone tell me where I am going wrong?</p>