X-ray polarimetry promises to deliver unique information about the geometry
of the inner accretion flow of astrophysical black holes and the nature of
matter and electromagnetism in and around neutron stars. In this paper, we
discuss the possibility to use Stokes parameters - a commonly used tool in
radio, infrared, and optical polarimetry - to analyze the data from X-ray
polarimeters such as scattering polarimeters and photoelectric effect
polarimeters, which measure the linear polarization of the detected X-rays.
Based on the azimuthal scattering angle (in the case of a scattering
polarimeter) or the azimuthal component of the angle of the electron ejection
(in the case of a photoelectric effect polarimeter), the Stokes parameters can
be calculated for each event recorded in the detector. Owing to the additive
nature of Stokes parameters, the analysis reduces to adding the Stokes
parameters of the individual events and subtracting the Stokes parameters
characterizing the background (if present). The main strength of this kind of
analysis is that the errors on the Stokes parameters can be computed easily and
are well behaved - in stark contrast of the errors on the polarization fraction
and polarization direction. We demonstrate the power of the Stokes analysis by
deriving several useful formulae, e.g. the expected error on the polarization
fraction and polarization direction for a detection of $N_S$ signal and
$N_{BG}$ background events, the optimal observation times of the signal and
background regions in the presence of non-negligible background contamination
of the signal, and the minimum detectable polarization (MDP) that can be
achieved when following this prescription.