Cumulative normal distribution function in object C

Does anyone know of a good implementation of this, whose license is compatible with non-free iPhone apps?

As suggested in this question, Boost looks absolutely wonderful. But, as far as I can tell, it is only available in C ++.

Aggregate normal distribution function in C / C ++

+4
source share
2 answers

Do not need anything. On any platform with good C99 math (e.g. iphone), there is already everything you need - in particular, the erfc function, which is a small option:

 #import <math.h> double cumulativeNormal(double x) { return 0.5 * erfc(-x * M_SQRT1_2); } 

Note that this is the standard normal distribution (i.e. average = 0, variance = 1), you will need to use the appropriate scaling - so for some average and variance, this will be:

 return 0.5 * erfc(((mean - x)/sqrt(variance)) * M_SQRT1_2); 

If you don't need double precision, change the paired numbers to float, use the erfcf function and change the literals to literals with the same precision.

Remember that Objective-C is an extremely easy extension for C. Each C function is an Objective-C function, without the need for wrapping or other fraud.

+12
source

So you specifically want an objective-c solution, right? Since just in case you still do not know, you can use C ++ libraries in your project .

+2
source

Source: https://habr.com/ru/post/1309068/


All Articles