The basic formula is: DPCT = average_damage * modifiers / effective_casting_time. (DPCT = Damage Per Cast Time)
average damage usually is easy: (min + max) / 2. min and max are given in the abiliity description. For dots (damage over time effects), sum all the damage it will do during its lifetime.
effective casting time frequently is easy as well: just read the ability description, and subtract bonusses from talent trees.
modifiers usually are the hard part. The descriptions of modifiers might be clear, but it seldomly is clear whether they are additive or multiplicative when combined.
And even if the description from the game is clear, it might be wrong. Tooltips are not always updated the same patch as the code that does the calculations. As SWTOR recently has had a beta with lots of balancing changes, it's a safe bet that some tooltips will be wrong!
Let me give an example: if two effects each increase damage by 10%, the combination could be 10% + 10% = 20% (additive) or 1.1*1.1 = 1.21 = 21% (multiplicative).
Not much of a difference, but elitistjerks will want to be as exact as possible. This is where things get time consuming: use the ability 1000 times, parse the combat log, and see whether it is closer to 20% or 21% on average. A basic knowledge of statistics might be required to know when you've parsed enough log files.
A quicker trick might be to observe the maximum possible. If the maximum hit is e.g. 100, and there are two 10% increasing effects active, a hit of 121 is a clear indication that the modifiers are multiplicative. If you are able to rule out other causes (other modifying effects, crits, level difference with target, ...).
It gets even harder when effects are coupled: e.g. a very good ability with a cooldown of 12 seconds, but only usuable when another effect with a chance of 25% to happen is active. One cannot assume that this ability will be used every 12 seconds, as that other effect might not be active when the cooldown is finished.
In those cases, it might be easier to simulate a combat. Repeat the simulation many times and take the average. Again: a basic knowledge of statistics might be required to know how many times the simulation should be repeated.
Those are the basics.
For more details, just read the elitistjerks posts. WoW is a complicated games, and has many effects, both multiplicative and additive, so formulas can appear to be complicated. However, the basics are still the same.
Once you grasp each and every detail of the simulations, and as a proof have written some simulations yourself, you might consider to change your job :). Those skills are highly wanted by e.g. banks and insurance companies...
Best Answer
The exact optimal stats are: 6410 Endurance | 5372 Mastery | 2931 Power 1309 Critical | 774 Alacrity | 701 Accuracy
To achieve this, you want Versatile armorings and hilt (for more Mastery), unlettered Lethal mods (for more Mastery and Power), 2 Initiative enhancements and 5 Accuracy augments (to get almost exactly 110% Accuracy), and the rest split approximately 2:1 between Crit and Alacrity. That means 2 Eviscerating crystals, 3 Crit and 6 Alacrity augments, and 6 Adept and 2 Quick Savant enhancements. Ideally, you want to get Hard Mode Operations tokens (Unassembled pieces) in order to exchange for Weaponmaster gear (which has the Guardian DPS set bonus armorings). Operations drops are also the only way to get the best Mods and Enhancements without crafting.
For the purposes of stat discussions, note that Implants and Earpieces count as Enhancements and are named similarly, with the addition of "MK-1" at the end for the best versions.
Please see this forum post for the mathematics behind these recommendations. The short version is that as a DPS you will always prioritize other stats over Endurance and so choose the low-endurance modifications. Crit is the most valuable stat but quickly enters diminishing returns as you acquire more of it — but Alacrity is also quite valuable and is affected much less by diminishing returns. Power is always less valuable than Crit in 4.0 (given current stat budgets) despite it having no diminishing returns at all, and Mastery (formerly the 4 main stats) continues to be heavily curbed. Oh, and you want that extra 10% Accuracy because it overcomes boss resistances.