Created attachment 25678 [details] This is the zip of the patch file and the junit test. I have implemented the Poisson function ( within the NumericFunctions ). This also had the implication that I needed to use another library ( common-math - as I need not want to reinvent ) but I have updated the ant build.xml appropriately. I have also supplied a unit test for this function. I have only done this very quickly therefore ( although it does work - with validation and a unit test) it would be good for someone to verify that my changes are ok within your framework. I have attached the addition file (unit test) but it seems that when I created the patch it has included this new file in it (I have used tortoiseSVN to create the patch). The zip poi-hssf-poisson-patch.zip is attached. Hope this is helpful. If not please ask for any other info. Regards, Kalpesh
I have updated the patch as I missed out the case where if x is a decimal excel will automatically truncate it (now it is compliant with the excel definition of the Poisson function) Regards, I have (as before) attached the zip file which contains the patch ( created as before ) and the updated junit test. poi-hssf-poisson-patch2.zip is now the one to use. Thanks Kalpesh
Created attachment 25712 [details] [Patch] The corrected Poisson implementation function Update of the first patch I posted. I have added additional details below.
Comment on attachment 25712 [details] [Patch] The corrected Poisson implementation function There is an updated patch that should be used. See details for the next attachment.
Created attachment 25725 [details] [Patch] The re-corrected Poisson implementation function Current version for the Poisson implemented fuinction.
Hi, I have provided yet another update for the patch I posted. The reason is that excel implementation for Poisson for x - 0 and mean - 0 is 1. This is different to that of commons implementation ( it errors which actually is what should happen ). I have followed the result that excel gives and now return a 1 in this case ( this I do not believe is right but its what excel does so I am being consistent with excel). The zip poi-hssf-poisson-patch3.zip is attached above ( contains the patch and updated junit test). Regards, Kalpesh
Thanks for the patch, applied in r979255 We had a debate whether to depend on commons-math or not and we think in the case of POISSON we can do without third party libraries, the implementation of Poisson distribution is really a few lines of code: private double probability(int k, double lambda) { return Math.pow(lambda, k) * Math.exp(-lambda) / factorial(k); } private double cumulativeProbability(int x, double lambda) { double result = 0; for(int k = 0; k <= x; k++){ result += probability(k, lambda); } return result; } Yegor