[Scilab-users] n dimensional normal distribution

classic Classic list List threaded Threaded
7 messages Options
fujimoto2005 fujimoto2005
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] n dimensional normal distribution

Let x1, x2, .., xn be an random variable of n dimensional normal
distribution. Is there any function that gives the probability of {x1> =
k1}&{x2> = k2}&...&{xn> = kn}?



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Christophe Dang Ngoc Chan Christophe Dang Ngoc Chan
Reply | Threaded
Open this post in threaded view
|

Re: {EXT} n dimensional normal distribution

Hello,

> De : fujimoto2005
> Envoyé : dimanche 18 mars 2018 17:32
>
> Let x1, x2, .., xn be an random variable of n dimensional normal distribution.
> Is there any function that gives the probability of {x1> = k1}&{x2> = k2}&...&{xn> = kn}?

I'm not sure I understand well your need.

You can have the cumulative distribution function of the normal law with cdfnor()

https://help.scilab.org/docs/6.0.1/en_US/cdfnor.html

In your case, the syntax is [P,Q]=cdfnor("PQ",X,Mean,Std)

So I guess the probability you're looking for would be the product of the Qs for all your single component.

Additional functions can be found in the CASCI Atoms module:
http://atoms.scilab.org/toolboxes/casci

HTH

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
fujimoto2005 fujimoto2005
Reply | Threaded
Open this post in threaded view
|

Re: n dimensional normal distribution

In reply to this post by fujimoto2005
Dear Chan
Thank for your reply.

" the product of the Qs for all your single component. " is a right answer
only when xis are independent.
I am looking for the function when they are not independent.

Best regards.



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Christophe Dang Ngoc Chan Christophe Dang Ngoc Chan
Reply | Threaded
Open this post in threaded view
|

Re: {EXT} Re: n dimensional normal distribution

Hello,

> De : fujimoto2005
> Envoyé : lundi 19 mars 2018 13:15
>
> " the product of the Qs for all your single component. " is a right answer only when xis are independent.
> I am looking for the function when they are not independent.

I'm afraid I can't help further;
Maybe if you can share a small example?

Otherwise, if you have strong needs I statistics, you may have a look at the R language

https://www.r-project.org/

although the syntax is a bit weird when you come from Scilab.

Regards

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
mottelet mottelet
Reply | Threaded
Open this post in threaded view
|

Re: n dimensional normal distribution

In reply to this post by fujimoto2005
Le 19/03/2018 à 13:15, fujimoto2005 a écrit :

> Dear Chan
> Thank for your reply.
>
> " the product of the Qs for all your single component. " is a right answer
> only when xis are independent.
> I am looking for the function when they are not independent.
>
> Best regards.
>
>
>
> --
> Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users

Hello,

R implements this in  the "TruncatedNormal" package
(https://cran.r-project.org/web/packages/TruncatedNormal/) :

The routines include (Quasi-) Monte Carlo estimator and a deterministic
upper bound of the cumulative distribution
function of the multivariate normal.

hth

S.

--
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: n dimensional normal distribution

In reply to this post by fujimoto2005
Hello Masahiro,

Le 18/03/2018 à 17:31, fujimoto2005 a écrit :
Let x1, x2, .., xn be an random variable of n dimensional normal
distribution. Is there any function that gives the probability of {x1> =
k1}&{x2> = k2}&...&{xn> = kn}?

I thougth at the first sight that it would be possible to get this probability with some lexicographic sorting, but it's not the case. I don't thing that we can avoid an explicit loop. Here is a possible direct calculation, from a list of actual samples :
ns = 20;    // number of samples
nd = 3;     // number of dimensions
k = [5 3 7];
m = grand(ns,nd,"nor",8,3)
for i = 1:nd
    [?,r] = gsort(m(:,i));
    m = m(r,:);
    m = m(find(m(:,i)>=k(i)),:)
end
p = size(m,1)/ns  // requested probability
Example of run :
 m  =
   12.750144   7.1200267   5.900484
   12.575508   5.410083    10.976422
   12.399993   3.7475677   10.092495
   12.220889   5.4940195   6.1479044
   12.158487   5.2062957   11.651957
   11.611694   6.6661928   5.9750098
   10.718146   2.2454739   11.737011
   10.343892   4.2714818   4.7199587
   9.9907016   7.7903253   5.9802778
   8.3135823   4.8094984   7.1769228
   8.0939865   9.2484944   13.215993
   8.0098652   3.0198012   7.5767533
   7.5354006   10.715856   8.985266
   7.4971339   17.821625   5.5456382
   6.6502306   8.7791304   8.812858
   6.5728805   12.299302   7.9823783
   6.2940806   10.376389   7.8221558
   5.2862072   6.0566186   11.102784

 m  =
   7.4971339   17.821625   5.5456382
   6.5728805   12.299302   7.9823783
   7.5354006   10.715856   8.985266
   6.2940806   10.376389   7.8221558
   8.0939865   9.2484944   13.215993
   6.6502306   8.7791304   8.812858
   9.9907016   7.7903253   5.9802778
   12.750144   7.1200267   5.900484
   11.611694   6.6661928   5.9750098
   5.2862072   6.0566186   11.102784
   12.220889   5.4940195   6.1479044
   12.575508   5.410083    10.976422
   12.158487   5.2062957   11.651957
   8.3135823   4.8094984   7.1769228
   10.343892   4.2714818   4.7199587

 m  =
   8.0939865   9.2484944   13.215993
   12.158487   5.2062957   11.651957
   5.2862072   6.0566186   11.102784
   12.575508   5.410083    10.976422
   7.5354006   10.715856   8.985266
   6.6502306   8.7791304   8.812858


--> p = size(m,1)/ns  // requested probability
 p  =
   0.3

Samuel


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
fujimoto2005 fujimoto2005
Reply | Threaded
Open this post in threaded view
|

Re: n dimensional normal distribution

Dear all.
Thank you for your answers.
I am sorry that the reply is delayed.

My original problem is v=∫∫..∫f(X1,X2,..,Xn,Y)n(X1,X2,..,Xn,Y)dX1dX2..dXndY
where n(X1,X2,..,Xn,Y) is a n+1 dimensional normal density function.

This is a problem of a mathematical finance and this integral is usually
calculated by numerical integration using random numbers.
In my problem f() has the following special form.
f(X1,X2,..,Xn,Y)=g(Y)I(x1>=k1)...I(Xn>=Kn) where I() is an indication
function.
In this case, v can be decomposed as v=∫g(Y){∫..∫n(X1,X2,..,Xn
|Y)dX1dX2..dXn}n(Y)dY= ∫g(Y)Prob[(X1>=K1)& ..&(Xn>=Kn)|Y}n(Y)dY where
n(X1,X2,..,Xn |Y) is a normal density conditiona to Y, Prob(..|Y) is a
probability conditional to Y and n(Y) is a one dimensional normal density
function.
This integration can be calculated firstly when n = 1 since Prob(x1>=K1|Y)
has an analytical approximate function.
When n = 2, it works still fine because Prob[(X1>=K1
&X2>=K2)|Y}=1-Prob[X1<=K1]-Prob[X2<=K2]+Prob[X1<=K1&X2<=K2] and I hear that
Prob[X1<=K1&X2<=K2] have an analytical approximate functions.

I posted the question because I can calculate it first if there is an
analytical approximate function of Prob[(X1>=K1)& ..,(Xn>=Kn)|Y} for large
n.
However, as Samuel demonstrated explicitly and Stéphane implicitly by
referring to R, it seems that there is no choice but to calculate
Prob[(X1>=K1)& ..,(Xn>=Kn)|Y} for large n by using random numbers.
I understand my prospects doesn’t go well because there is no such function
for large n.
When using random numbers, it is the best way to calculate v in the original
form.

Best regards.




--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users