1. A computer-implemented method for optimizing a radiation treatment plan for a radiotherapy machine providing independently controlled radiation along a plurality of rays j directed toward a patient configured to account for the effects of patient motion, comprising: a) generating a probability distribution function quantitatively expressing patient motion; b) identifying a prescribed total dose D i p at the voxels i in a treatment area; c) assigning a fluence value w j for each ray j, based on an iterative function: w j ( k + 1 ) = w j k N ∑ m = 1 M C m ∑ i ∈ τ m 〈 d ij 〉 D i p ( N - 1 ) ∑ m = 1 M C m ∑ i ∈ τ m 〈 D i d k 〉 〈 d ij 〉 + ∑ m = 1 M C m ∑ i ∈ τ m 〈 d ij D i d k 〉 , ( 6 ) where N is the number of treatment fractions, D i p is the planned dose to voxel i, D i d k is the motion-uncorrected dose to voxel i for iteration k, and C m is a weighting factor assigned to structure m, which may be either a tumor or sensitive area; d) calculating an actual total dose D i d produced in each voxel i within the assigned fluence values of step (c); and e) calculating an expectation value of the dose per energy fluence, d ij based on the actual total dose D i d and the probability distribution function.