In this paper, the current methods that are used for deriving the Gaussian cost function in four-dimensional variational (4D VAR) data assimilation, are extended to lognormal and mixed, lognormal and Gaussian, random variables (rv). It is also shown that transforming a lognormal rv into a Gaussian rv to use in a Gaussian based 4D VAR results in the analysis state being similar to a median in lognormal space. An alternative version of the functional approach is derived so that the minimum of this alternative cost function is the mode in lognormal space. However, the current approaches do not allow for a generalized probability density function (pdf) approach, to overcome this a general probability model is derived so that the mode is found for any pdf from Bayesian networks and conditional independence properties. It is shown that the current Gaussian cost function and the lognormal can be found by the probability model method. The paper is finished by comparing the median approach with the modal approach in the Lorenz 1963 model for both weak and strong constraint 4D VAR and show that the mode is a more reliable analysis statistic than the median under certain circumstances.