How to acquire prior distribution is a key to Bayes method. Firstly, a nonlinear constrained optimal model of probability density function based on the principle of maximum entropy is set up. By using Lagrange multiplier this constrained optimal problem is transformed to a non-constrained optimal one, which is solved by standard particle swarm optimization (PSO) algorithm. Secondly, a new improved particle swarm optimization (IPSO) algorithm is proposed because standard PSO is slow on convergence and easy to be trapped in local optimum. IPSO introduces the hybrid method from genetic algorithm (GA) so that the overall searching ability is enhanced; then linear decreasing inertia weight is used to optimize particles. The simulation examples show that IPSO is simple and effective and it can rapidly converge with high quality solutions.