Very useful. I had done a similar thing with the EMG, but much more clumsy.... Heinz
> On 29.04.2024, at 16:41, Federico Miyara <fmiy...@fceia.unr.edu.ar> wrote: > > > Heinz, > > I don't know if this might be useful. The function I'm attaching allows to > generate random numbers according to any distribution, either empirical or > analytical. The results may be scaled if necessary. > > Regards, > > Federico Miyara > > > On 29/4/2024 00:11, Heinz Nabielek wrote: >> Colleagues: >> >> bird flight altitude probabilities are given by the exponentially modified >> Gaussian distribution EMG f=f(h), in my case >> >> f = (a/2)*exp((a/2)*((a*σ^2)-2*h)) .* erfc((a*σ^2-h)/σ/sqrt(2)) >> >> with h=hmeasured-85 in meters, a=1/60m, σ=30m. See: >> <https://en.wikipedia.org/wiki/Exponentially_modified_Gaussian_distribution>. >> >> For bird flight Monte-Carlo simulations, I need random deviates representing >> this distribution. >> Normally, I generate the cumulative function F of f. Then, I project uniform >> random numbers U(0,1) on F^-1, the inverse of the cumulative. >> >> With the EMG, closed solutions are not available and I need a numerial >> procedure to generate EMG deviates. >> What is the best way to do this? >> Best greetings >> Heinz >> This email and any attachments are intended solely for the use of the >> individual or entity to whom it is addressed and may be confidential and/or >> privileged. >> >> If you are not one of the named recipients or have received this email in >> error, >> >> (i) you should not read, disclose, or copy it, >> >> (ii) please notify sender of your receipt by reply email and delete this >> email and all attachments, >> >> (iii) Dassault Systèmes does not accept or assume any liability or >> responsibility for any use of or reliance on this email. >> >> >> Please be informed that your personal data are processed according to our >> data privacy policy as described on our website. Should you have any >> questions related to personal data protection, please contact 3DS Data >> Protection Officer https://www.3ds.com/privacy-policy/contact/ >> >> >> >> >> >> _______________________________________________ >> users mailing list - users@lists.scilab.org >> Click here to unsubscribe: <mailto:users-unsubscr...@lists.scilab.org> >> https://lists.scilab.org/mailman/listinfo/users > > > -- > Este correo electrónico ha sido analizado en busca de virus por el software > antivirus de Avast. > www.avast.com This email and any attachments are intended solely for the use of the individual or entity to whom it is addressed and may be confidential and/or privileged. If you are not one of the named recipients or have received this email in error, (i) you should not read, disclose, or copy it, (ii) please notify sender of your receipt by reply email and delete this email and all attachments, (iii) Dassault Systèmes does not accept or assume any liability or responsibility for any use of or reliance on this email. Please be informed that your personal data are processed according to our data privacy policy as described on our website. Should you have any questions related to personal data protection, please contact 3DS Data Protection Officer https://www.3ds.com/privacy-policy/contact/
function x = rand_weighted(w, N) // This function generates N random numbers in the unit // interval according to an empirical statistical // distribution given by vector w // // Usage: // x = rand_weighted(w, N) // // where // x: vector containing random numbers // w: vector specifying the statistical distribution // as the probabilities in equally-wide bins along // the unit interval // N: number of random numbers to be created // // NOTES: 1) Vector w is a probability function, so sum(w) // must be equal to 1 // 2) A simple linear transformation such as // y = a + x*(b - a) // may be used to get a distribution over the // interval from a to b // 3) The number M of bins is arbitrary, but as // an interpolation is performed, as M gets // larger the accusacy improves. Usually M // depends on the size of the sample data used // to estimate the empirical distribution // // -------------------------------------------- // Author: Federico Miyara // Date: 2017-02-06 // 2020-03-12 // 2023-11-05 M = length(w); // Cumulative probability including 0 W = cumsum([0,w]); // The inverse function of the cumulative probability (obtained by // linear interpolation) is obtained for a uniformly distributed set // of N random numbers between 0 and 1 x = interp1(W, [0:M]/M, rand(1,N), "spline"); endfunction
_______________________________________________ users mailing list - users@lists.scilab.org Click here to unsubscribe: <mailto:users-unsubscr...@lists.scilab.org> https://lists.scilab.org/mailman/listinfo/users