Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Generate random numbers from a particular function
Date: Tue, 1 Jun 2010 00:19:05 +0000 (UTC)
Organization: Florida Institute of Technology
Lines: 36
Message-ID: <hu1jlp$hs1$1@fred.mathworks.com>
References: <hu1c4b$5t7$1@fred.mathworks.com> <hu1h27$e6l$1@canopus.cc.umanitoba.ca>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1275351545 18305 172.30.248.35 (1 Jun 2010 00:19:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 1 Jun 2010 00:19:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 934319
Xref: news.mathworks.com comp.soft-sys.matlab:641024

Thanks Walter,

I found the coefficients with a nonlinear regression to be:

p = [4.4786   16.8696   28.0379    3.3347    1.9488];

Could you explain a little more how to solve numerically??

thanks a lot,

Gonzalo

Walter Roberson <roberson@hushmail.com> wrote in message <hu1h27$e6l$1@canopus.cc.umanitoba.ca>...
> 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.