Though it may sometimes seem like it, stock prices aren't random. And the best investors know it. So how do investors decide whether or not a stock is a "buy"?

Valuation.

Discount your cash
Put simply, valuation is the most important math in stock investing.

You can calculate valuations in a number of ways. One of the most popular among investors is the discounted cash flow model, otherwise known as DCF. Here's how Investopedia defines DCF:

A valuation method used to estimate the attractiveness of an investment opportunity. DCF analysis uses future free cash flow projections and discounts them (most often using the weighted average cost of capital) to arrive at a present value, which is used to evaluate the potential for investment. If the value arrived at through DCF analysis is higher than the current cost of the investment, the opportunity may be a good one.

Confused? At first I was, too. All you really need to understand is that DCF projects a company's future cash flows and decides what they're worth today.

If you're a novice, the best way to try your hand at DCF is with a DCF calculator. Subscribers to Motley Fool Inside Valuehave access to one. Moneychimp has one, too.

Doing your first DCF
As you might expect, these automated systems trade precision for ease of use. But even they don't spare you from all the work. You're still going to have to find or calculate some inputs. Let's run through the laundry list of what's required:

• Free cash flow or earnings per share: Most often, your base figure will be free cash flow or earnings from the trailing 12 months, which you may find at Yahoo! Finance under "Key Statistics." You're going to need per-share figures, so be sure to also write down how many shares are outstanding.

• Growth rates: Here, you'll be relying on analyst projections and maybe even your own instincts. Why? Some calculators, like the one at Inside Value, require that you determine growth for the first five years, the next five, and then a terminal rate. Two of three are easy; five-year consensus growth rates are available for thousands of stocks at Yahoo! Finance, under "Analyst Estimates." Meanwhile, the terminal rate can be made to match the historic rate of inflation, or 3%. Years six to 10, however, are dicey, because analysts tend to not project that far into the future. And that leaves you with two alternatives: waving your arms, or using the long-term return of stocks, or 7%, as a proxy.

• Discount rate: Generating a discount rate can either be really difficult, or really easy; it all depends on how much work you want to do. One school of thought believes that the discount rate should be the weighted average cost of capital, otherwise known as the cost of equity plus the cost of debt. Investopedia has the formula if you want to try calculating it yourself. The easier way, however, is to paint with broad strokes at first, then become more precise if you've found a compelling idea. Inside Value advisor Philip Durell advises quick-and-dirty 9% to 12% discount rates for blue chips such as ExxonMobil (NYSE:XOM) and Procter & Gamble (NYSE:PG), 11% to 14% for mid-caps such as Expeditors International (NASDAQ:EXPD) and Cognizant Technology Solutions (NASDAQ:CTSH), and 15% or more for small caps such as Frontier Oil (NYSE:FTO) and Toro (NYSE:TTC).

Ready to try this for yourself? Let's use IBM (NYSE:IBM) as our guinea pig. My inputs for the DCF calculator at Inside Value are:

• \$11.4 billion in trailing-12-month free cash flow.
• 11%, growth for years one to five, 7% growth for years six to 10, and 3% terminally.
• 1.52 billion shares outstanding.
• And a 9% discount rate, since IBM is among the bluest of the blue-chip stocks.

Plugging in the totals results in a fair value of -- wow -- \$206 a share. If that's even close to correct, then IBM, trading for just less than \$82 a stub as of yesterday's close, is remarkably cheap.

Follow the money
But it may not be. Valuation is as much an art as it is a science, because the quality of the output is only as good as the numbers entered into the model. Frankly, any or all of the assumptions I made with respect to IBM may be far off, and if I play around with the numbers a little bit, the calculator will spit back a fair value much closer to today's price. We'll delve into this problem more next week, when we explore valuation using multiples to earnings.

Have other money tips? Tell me. I'm writing new articles on personal finance and investing basics every week as part of our new beginner investing and personal-finance service, Motley Fool GreenLight. It's tailor-made for Fools like you who aim to take control of their financial destiny. Click here to learn more.

Fool contributor Tim Beyers actually does believe IBM is cheap. Tim didn't own shares in any of the companies mentioned in this story at the time of publication. Get a peek at everything he's invested in by checking his Fool profile. The Motley Fool's disclosure policy is sharply undervalued.