       else
         x_new.push @data.x[i]
         y_new.push @data.y[i]
+
+    # normalize
+    yMax = Math.max y_new...
+    yMin = Math.min y_new...
+    yMean = @mean(y_new)
+    for y, i in [ y_new... ]
+      y_new[i] = (y-yMin)/(yMax-yMin)
+    # y_new[i] = y_new[i] / yMean
+
     @data.x = x_new
     @data.y = y_new
+
 
   std: (data) ->
     mean = @mean(data)

    window.marks = @marks
    @canvas.addEventListener 'mousedown', (e) => @addMarkToGraph(e)
    @canvas.addEventListener 'touchstart', (e) => @addMarkToGraph(e)

  # drawYTickMarks: (domain, range, minorInt, majorInt) ->
  #   # draw scales
  #   tickMinorInterval = minorInt
  #   tickMajorInterval = majorInt
  #   tickMinorLength = 5
  #   tickMajorLength = 10
  #   tickWidth = 1
  #   tickColor = '#323232'
  #   textColor = '#323232'
  #   textSpacing = 15

  #   domainMin = Math.min(domain...)
  #   domainMax = Math.max(domain...)
  #   rangeMin = Math.min(range...)
  #   rangeMax = Math.max(range...)

  #   for i in domain
  #     # do not draw first, last tickmarks
  #     continue unless i isnt +Math.max(domain...)-1
  #     continue unless i isnt +Math.min(domain...)+1
  
  #     # draw minor tickmarks
  #     tick_y = Math.round ( (( +i - domainMin) / (domainMax - domainMin)) * rangeMax )
  #     if i % majorInt is 0
  #       @ctx.beginPath()
  #       @ctx.moveTo( rangeMin, tick_y )
  #       @ctx.lineTo( rangeMin+tickMajorLength, tick_y )
  #       @ctx.lineWidth = tickWidth
  #       @ctx.strokeStyle = tickColor
  #       @ctx.stroke()
  #     else if i % minorInt is 0
  #       @ctx.beginPath()
  #       @ctx.moveTo( rangeMin, tick_y )
  #       @ctx.lineTo( rangeMin+tickMinorLength, tick_y )
  #       @ctx.lineWidth = tickWidth
  #       @ctx.strokeStyle = tickColor
  #       @ctx.stroke()
  #       # print labels
  #       @ctx.font = '10pt Arial'
  #       @ctx.textAlign = 'center'
  #       @ctx.fillStyle = textColor
  #       y_scaled = 1 - +i/domainMax
  #       @ctx.fillText( y_scaled.toFixed(2), rangeMin+tickMajorLength+textSpacing, tick_y+tickMinorLength )

  removeOutliers: (nsigma) ->
    mean = @mean(@data.y)

      @data.x[idx] = xValue - @smallestX

    # remove outliers and normalize
    @removeOutliers(nsigma=3)

    # update min/max values
    @smallestX = Math.min @data.x...
    @smallestY = Math.min @data.y...
    @largestX = Math.max  @data.x...
    @largestY = Math.max  @data.y...

  disableMarking: ->
    @markingDisabled = true
