# Fitting a Line to Your Data

After you have done the experiment part of your Science Fair Project, you will most likely have some data that you recorded (for example, time and distance). In most situations, you will have two variables that you are comparing. One variable is called the independent variable, the other is called the dependent variable.

## Independent or Dependent?

How can I figure out which variable is independent and which variable is dependent? There are a couple ways to think about it:

- The variable you started with is the independent variable; the variable you got as a result is the dependent variable.
- Which variable is input, which variable is output? Input is the independent variable, Output is the dependent variable.
- Ask yourself the question, Does variable 1 depend on variable 2, or does variable 2 depend on variable 1? (You fill in your appropriate variables.) This determines the dependent variable.
- If time is one of your variables, it is the independent variable. Time is always the independent variable. The other variable is the dependent variable (in our example: time is the independent variable and distance is the dependent variable).

## Why does it matter if the variable is independent or dependent?

This is the easy part. The independent variable is represented by the `x` axis, and the dependent variable is represented by the `y` axis on your graph.

Then simply plot the points where the values coincide. You may be able to connect these points to form a line (or come fairly close). This is where line fitting comes in.

For example, If we are given two points (`x _{1}, y_{1}`) and (

`x`) there is only one line that can pass through both of them.

_{2}, y_{2}If, however, we have more than two points we will not generally be able to find a line that exactly fits the data. There is still one line that best represents the data, but it does not follow through each point.

The mathematical technique to find a line (or curve) that best matches the points of data that you collected is called regression.

## How to do Linear Regression and include it in your results:

- This technique can be accomplished using Microsoft Excel or by using free Open Office Software, which is demonstrated on our Excel Linear Regression. webpage.
- If you do not have access to Microsoft Excel, you can still do the process by hand quite easily. A step by step calculation is demonstrated on our Hand Linear Regression webpage.
- For a rigorous explanation of this see Wikipedia's Linear Regression webpage.