From: Gonzalo on
Hi all,

I need to generate RN's from a double hyperbolic tangent function.

f(x) = p(1) .* (tanh((x - p(2)) ./ p(4))- tanh((x - p(3)) ./ p(5))

I can't do it using the inverse-transform method because it's not possible to solve for x. Does anybody know of a routine that works the Composition, or convolution or any other methods??

Thanks
From: Walter Roberson on
Gonzalo wrote:

> I need to generate RN's from a double hyperbolic tangent function.
>
> f(x) = p(1) .* (tanh((x - p(2)) ./ p(4))- tanh((x - p(3)) ./ p(5))
>
> I can't do it using the inverse-transform method because it's not
> possible to solve for x. Does anybody know of a routine that works the
> Composition, or convolution or any other methods??

x can be solved for numerically given the other parameters. The key value to
be solved for is,

RootOf(2*_Z*p(5)-2*p(3)+2*p(2)-p(4)*ln((p(1)*exp(_Z)^2+p(1)+exp(_Z)^2-1)/(p(1)*
exp(_Z)^2+p(1)-exp(_Z)^2+1)))

where RootOf is a notation indicating that the value _Z should be found such
that the expression evaluates to 0 at _Z .

However, for some combinations of parameters, some of the x might be
imaginary. For example, p(1)=1/2, p(2)=1/3, p(3)=1/5, p(4)=1/7 and p(5) from
about 0.18 to about 0.54, whereas with p(1)=2, p(2)=3, p(3)=5, p(4)=7 then in
my experiments I do not see any p(5) that would make the expression imaginary.