---
  title: "Reducer"
  description: "Documented Methods"
  sections: 
    - 
      type: "markdown-section"
      content: "DataModel\n\nReducer is just a simple function which takes an array of real numbers and returns a representative number by\nreducing the array. A reducer can only be applied on a measure.\n\nDataModel provided reducers which can be used out of the box\n <table>\n     <tr>\n         <th>Reducer Name</th>\n         <th>Description</th>\n     </tr>\n     <tr>\n         <td>sum</td>\n         <td>returns the sum of all the number</td>\n     </tr>\n     <tr>\n         <td>avg</td>\n         <td>returns the avg of all the number</td>\n     </tr>\n     <tr>\n         <td>min</td>\n         <td>returns the minimum of all the number</td>\n     </tr>\n     <tr>\n         <td>max</td>\n         <td>returns the maximum of all the number</td>\n     </tr>\n     <tr>\n         <td>first</td>\n         <td>returns the first number</td>\n     </tr>\n     <tr>\n         <td>last</td>\n         <td>returns the last number</td>\n     </tr>\n     <tr>\n         <td>count</td>\n         <td>returns number of elements in the array</td>\n     </tr>\n     <tr>\n         <td>variance</td>\n         <td>returns the variance of the numbers from the mean</td>\n     </tr>\n     <tr>\n         <td>std</td>\n         <td>returns the standard deviation of the numbers</td>\n     </tr>\n </table>"
    - 
      type: "markdown-section"
      content: "<p class=\"sub-header\">Parameters:</p>\n<table><thead><tr><td>Name</td><td>Type</td><td>Description</td></tr></thead>\n<tr>\n                <td class=\"param-name\">arr</td>\n                <td><p>Array of Number</p> </td>\n                <td><p>array of numbers which needs to be reduced to a single number.</p> </td>\n            </tr></table>"
    - 
      type: "code-section"
      content: "// An function to calculate mean squared value of an array.\nfunction (arr) {\n     const squaredVal = arr.map(item => item * item);\n     let sum = 0;\n     for (let i = 0, l = squaredVal.length; i < l; i++) {\n         sum += squaredVal[i];\n     }\n\n     return sum;\n }"
      preamble: ""
    - 
      type: "markdown-section"
      content: "<a name=Number></a><p class=\"sub-header\">Returns:</p>\n\n <span style=\"font-family: 'Source Code Pro';margin-left: 2%;\">Number:</span>single representative number"
