title: how can I rewrite, and optimize, this EMA calculation in F#
body: <p>this is an EMA calculation:</p>
  
  <pre><code>let EMA (period : int) (data : double[]) : double[] =
      let multiplier = 2.0 / (double)(period + 1)
      let output = Array.create data.Length System.Double.NaN 
  
      output.[period - 1] &lt;- data.[0..period - 1] |&gt; Seq.average
      for i in seq {period .. (data.Length - 1)} do
          output.[i] &lt;- (data.[i] * multiplier) + (output.[i - 1] * (1. - multiplier))
  
      output
  </code></pre>
  
  <p>you can test it with:</p>
  
  <pre><code>EMA 3 [|1.;3.;4.;7.;5.;6.;9.;8.|]
  </code></pre>
  
  <p>and it gives:</p>
  
  <pre><code>[|NaN;Nan;2.66.;4.83;4.91;5.45;7.22;7.61|]
  </code></pre>
  
  <p>my first question is regarding the loop at the end:</p>
  
  <pre><code>for i in seq {period .. (data.Length - 1)} do
      output.[i] &lt;- (data.[i] * multiplier) + (output.[i - 1] * (1. - multiplier))
  </code></pre>
  
  <p>can this be rewritten using a sequence operator?</p>
  
  <p>my second question is: is there a fast F# implementation floating around? I couldn't find any.</p>