The likelihood function l(X|q) is a function of q with the data X fixed. It calculates the joint probability density or mass of the X observed data as a function of q. Sometimes the likelihood function is simple: often it is just the probability distribution function of a distribution like the Binomial, Poisson or Hypergeometric. At other times, it can quickly become very complex.
The likelihood principle states that all relevant evidence about q from an experiment and its observed outcome should be present in the likelihood function. For example, in binomial sampling with n fixed, s is binomially distributed for a given p. If s is fixed, n is negative binomially distributed for a given p. In both cases the likelihood function is proportional to ps(1-p)n-s, i.e. it is independent of how the sampling was carried out and dependent only on the type of sampling and the result.
Since the likelihood function depends entirely on the stochastic process that generated the observations, you will need to become familiar with the basic stochastic processes, and then we suggest that you work through the examples we provide.