trunc_normal is missing from this code snippet.
Truncated standard normal example is in the How To chapter of the Ox book (p.46):
pa = probn(a); // Pr{value <= a}
// pa = 0 for no left truncation
pb = probn(b); // Pr{value <= b}
// pb = 1 for no right truncation
y = quann( pa + ranu(1000,1) * (pb - pa) );
Jurgen
oxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxox
oxoxoxox Oxford Summer School 2012, 7-14 July
oxoxoxox 12th OxMetrics user conference 2012
oxoxoxox Cass Business School, London, 3-4 September
oxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxox
Dr Jurgen A Doornik
James Martin Fellow, Institute for New Economic Thinking
at the Oxford Martin School, University of Oxford
tel. UK: +44-1865-278610 at Nuffield College
http://www.doornik.com
http://www.oxmetrics.net
oxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxox
On 2012-06-14 23:20, Bruemmer, Bernhard wrote:
> Dear Rui,
>
> as Jaap de Vries posted some time ago on this list, you can use this function:
>
> general_trunc_normal(const N, const mu, const sigma2, const left_truncation,
> const right_truncation)
>
> {
>
> return mu + sqrt(sigma2) * trunc_normal( N,
>
> (left_truncation - mu) / sqrt(sigma2),
>
> (right_truncation - mu) / sqrt(sigma2)
>
> );
>
> }
>
> With best regards,
>
> Bernhard
>
> *From:*The ox-users list is aimed at all Ox users
> [mailto:[log in to unmask]] *On Behalf Of *Rui Gao
> *Sent:* Thursday, June 14, 2012 11:13 PM
> *To:* [log in to unmask]
> *Subject:* sampling from truncated normal distribution
>
> Hi,
>
> Does anyone know whether there is a function in ox that I can use to generate
> random samples from truncated normal distributions?
>
> Thanks
>
> Rui
>
|