markrogoyski / math-php

Powerful modern math library for PHP: Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra
MIT License
2.32k stars 238 forks source link

Multivariate normal distribution CDF #257

Open xscheme opened 6 years ago

xscheme commented 6 years ago

dear markrogoyski:

I was requesting for this feature earlier.

I notice the name spaces Multivariate/Normal is added in your recent release. https://github.com/markrogoyski/math-php/blob/master/src/Probability/Distribution/Multivariate/Normal.php

However, only the probability density function is available now. The cumulative distribution function is still not available. My use case is actually on the cumulative distribution function.

Please check this function multi_normal_cdf (calculating multivariate CDF): https://github.com/xscheme/exotic_options/blob/master/options.inc.php

Until multivariate CDF is available, i have to rely on external R script calling approach.

xscheme

markrogoyski commented 6 years ago

Hi, Thank you for your continued interest in MathPHP. I apologize that we are lacking some functionality you'd like to use.

I am not familiar with how to compute the multivariate CDF, and the Multivariate Normal Wikipedia page does not provide details on how to do it. So I will have to research this first before I can try to implement it.

If someone knows an algorithm and can provide examples for test data that would be helpful.

I will update this issue when there is progress on implementing this feature. Thank you for your patience.

xscheme commented 6 years ago

Got you. I thought you were from the Maths background.

Let me work this problem out, and do some contribution to this great library :)

Beakerboy commented 6 years ago

@xscheme even people with a ‘maths background’ have specialties. Not all math majors specialize in multivariate statistics. As info, I’m a biochemical engineer.

xscheme commented 6 years ago

My initial research indicates, this might be a difficult problem.

The R version function mvrnorm is contributed by the researcher Alan Genz himself. He has been working on this numerical solution to multivariate distribution many years. The R solution internally calls C function, which further uses the PSCAL codes :(

http://www.sci.wsu.edu/math/faculty/genz/homepage

Please do not close this issue for this moment. I shall put more solid information later for discussion.