# Linear Regression and Correlation

 In statistics, a linear regression is an approach to model the relationship between a scalar dependent variable y and one or more explanatory variables denoted x, and the correlation is a statistical measurement that describes the dependence between both variables. . This tool retrieves for the linear relationship between x and y values (the formula y= ax+b) and the Pearson correlation coefficient (r) that describes the degree that linear dependence. To use this tool, just include in the form x values and the dependent variables y. Each value for x and y must be separated by a line break, and the same number of values for x and y are required. Often, non-linear relationships between two variables are linealized by applying to x or y values their logaritm or squares. You may do it when required by checking the corresponding checkboxes.

 Values for x:10 20 30 40 50 60 70 80 90 100 Apply to x values Log x x2 Values for y:31 58 93 125 144 177 209 249 270 303 Apply to y values Log y y2 example

 Values for curve y=ax+b a = 3.03 b = -0.67 Correlation (r) = 0.999

 Example: The number of apples arriving to the restaurant per box and their weight in kilograms were registered. Data is shown in the form above. We want to estimate the number of apples in a box when a new box arrives to the restaurant, so that we may decide the number of menus with apples we may offer to our clients. We have computed the linear regresión between both parameters and we have obtained the value a=3.03 and b=-0.67 to be used in the formula y=ax+b. When a 35 kilos box arrives to the restaurant, by applying the formula the number of apples in the box is easily estimated: y= 3.03 *35 + -0.67 = 105 apples As correlation coefficient is good (r = 0.999), the number of apples computed will be a good estimation.

Source code available at biophp.org