A method for optimizing a capacity of a communication channel in a communication system comprising at least a transmitter, a receiver, said communication channel between the transmitter and the receiver, and a channel conditional probability distribution estimator; the transmitter transmitting messages conveyed by a signal associated with a transmission probability according to an input signal probability distribution estimated by said estimator, the transmitter taking at least the messages as inputs and outputting the signal to be transmitted on the channel, said channel taking the transmitted signal as an input and outputting a received signal which is processed at the receiver in order to decode the transmitted message, a probability distribution being noted p Y | X ( y | x) relating to an output Y, corresponding to the received signal, given an input X, corresponding to the transmitted signal X, and representing thus a channel conditional probability distribution of a probability of outputting a received signal Y, when the transmitted signal X is given, wherein the probability distribution is estimated, by the channel conditional probability distribution estimator, as an approximation of the channel conditiona probability distribution p Y | X ( y | x) by using a functional basis of probability distributions, the channel conditional probability distribution being thus approximated, for each possible signal sent by the transmitter, by a mixture model with mixing probability distributions from said functional basis, the probability distribution for each possible transmitted signal being estimated from at least output signals received at the receiver, and using a collapsed Gibbs sampling relying on a Dirichlet process, and wherein the method comprises at least a training mode where the input X is known and said estimated probability distribution p Y | X ( y | x) is provided, by the channel conditional probability distribution estimator, at least to the receiver to learn the channe conditional probability distribution. the transmitter transmitting messages conveyed by a signal associated with a transmission probability according to an input signal probability distribution estimated by said estimator, the transmitter taking at least the messages as inputs and outputting the signal to be transmitted on the channel, said channel taking the transmitted signal as an input and outputting a received signal which is processed at the receiver in order to decode the transmitted message, a probability distribution being noted p Y | X ( y | x) relating to an output Y, corresponding to the received signal, given an input X, corresponding to the transmitted signal X, and representing thus a channel conditional probability distribution of a probability of outputting a received signal Y, when the transmitted signal X is given, wherein the probability distribution is estimated, by the channel conditional probability distribution estimator, as an approximation of the channel conditiona probability distribution p Y | X ( y | x) by using a functional basis of probability distributions, the channel conditional probability distribution being thus approximated, for each possible signal sent by the transmitter, by a mixture model with mixing probability distributions from said functional basis, the probability distribution for each possible transmitted signal being estimated from at least output signals received at the receiver, and using a collapsed Gibbs sampling relying on a Dirichlet process, and wherein the method comprises at least a training mode where the input X is known and said estimated probability distribution p Y | X ( y | x) is provided, by the channel conditional probability distribution estimator, at least to the receiver to learn the channe conditional probability distribution.