We study real-valued solutions of the equation \( \varphi (x)=\sum ^n_{j=1}p_j(x)\varphi \left( f_j(x)\right) \) as well as its multiplicative version \( \psi (x)=\prod ^n_{j=1}\psi \left( f_j(x)\right) ^{p_j(x)}. \) Both find interesting applications in probability theory, mainly in various characterization problems. As a corollary we obtain a new characterization of the exponential function. The results generalize a number of theorems proved by M. Kuczma, B. Choczewski and R. Ger, J.A. Baker, M.C. Zdun also a previous one proved by the author and W. Jarczyk.