  In previous works, we proposed to estimate cosmological parameters with the
artificial neural network (ANN) and the mixture density network (MDN). In this
work, we propose an improved method called the mixture neural network (MNN) to
achieve parameter estimation by combining ANN and MDN, which can overcome
shortcomings of the ANN and MDN methods. Besides, we propose sampling
parameters in a hyper-ellipsoid for the generation of the training set, which
makes the parameter estimation more efficient. A high-fidelity posterior
distribution can be obtained using $\mathcal{O}(10^2)$ forward simulation
samples. In addition, we develop a code-named CoLFI for parameter estimation,
which incorporates the advantages of MNN, ANN, and MDN, and is suitable for any
parameter estimation of complicated models in a wide range of scientific
fields. CoLFI provides a more efficient way for parameter estimation,
especially for cases where the likelihood function is intractable or
cosmological models are complex and resource-consuming. It can learn the
conditional probability density $p(\boldsymbol\theta|\boldsymbol{d})$ using
samples generated by models, and the posterior distribution
$p(\boldsymbol\theta|\boldsymbol{d}_0)$ can be obtained for a given
observational data $\boldsymbol{d}_0$. We tested the MNN using power spectra of
the cosmic microwave background and Type Ia supernovae and obtained almost the
same result as the Markov Chain Monte Carlo method. The numerical difference
only exists at the level of $\mathcal{O}(10^{-2}\sigma)$. The method can be
extended to higher-dimensional data.
