QB64 Phoenix Edition
erf() - The Gauss error function - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2)
+--- Thread: erf() - The Gauss error function (/showthread.php?tid=2164)



erf() - The Gauss error function - BSpinoza - 11-14-2023

This calculates the Gauss error function and the complementary Gauss error function:
Code: (Select All)

'The Gauss error function and the complementary Gauss error function
DIM AS _FLOAT a, n
a = 0.05
PRINT erf##(a)
PRINT erfc##(a)

FUNCTION erf## (value AS DOUBLE) 'the Gauss error function
    t## = 1 / (1 + 0.5 * ABS(value))
    tau## = t## * EXP(-value ^ 2 - 1.26551223 + 1.00002368 * t## + 0.37409196 * t## ^ 2 + 0.09678418 * t## ^ 3 - 0.18628806 * t## ^ 4 + 0.27886807 * t## ^ 5 - 1.13520398 * t## ^ 6 + 1.48851587 * t## ^ 7 - 0.82215223 * t## ^ 8 + 0.17087277 * t## ^ 9)
    IF value >= 0 THEN
        erf## = 1 - tau##
    ELSEIF value < 0 THEN
        erf## = tau## - 1
    END IF
END FUNCTION


FUNCTION erfc## (value AS DOUBLE) 'the complementary Gauss error function
    erfc## = 1 - erf##(value)
END FUNCTION
  

This are standard functions of many math libraries of other programming languages.


RE: erf() - The Gauss error function - SMcNeill - 11-14-2023

Hey!  A FUNCTION!!

I give it a number!  It returns a number!  Now what these numbers do, how I'd make use of them, or why I'd ever need them is completely beyond me.  Too bad there's no demo showcasing their functionality, nor any description of their reason for existence, but at least they're functions!


RE: erf() - The Gauss error function - BSpinoza - 11-14-2023

https://en.wikipedia.org/wiki/Error_function

... only a function, but a nice function!
Isn't it?


RE: erf() - The Gauss error function - Dimster - 11-14-2023

How does the variable " n " factor into this Error Function ( ie Dim as _Float a,n) ? Is this the variable holding the results of the function? If so, how does it hold that value if there is no assignment statement in the code.


RE: erf() - The Gauss error function - bplus - 11-14-2023

(11-14-2023, 07:28 AM)BSpinoza Wrote: https://en.wikipedia.org/wiki/Error_function

... only a function, but a nice function!
Isn't it?

Looks like a great way to make the letter S continuous over infiniy in both directions.
erf# ? A: Is the sound the S makes being stretched like that ;-))

Haven't I seen something like this function for Neural Net setup and training?


RE: erf() - The Gauss error function - BSpinoza - 11-14-2023

(11-14-2023, 03:18 PM)Dimster Wrote: How does the variable " n " factor into this Error Function ( ie Dim as _Float a,n) ? Is this the variable holding the results of the function? If so, how does it hold that value if there is no assignment statement in the code.
the 'n' isn't necessary, you can remove it.


RE: erf() - The Gauss error function - Kernelpanic - 11-14-2023

As I understand it, Gaussian-Error function is a way to determine the degree of error in something. For example: opinion polls.
1500 people are asked which party they want to vote for or intend to vote for. The result can never be 100% (safety). The question here is always: How high is the error quotient?
The Gaussian-Error function should provide a reliable answer here - or I misunderstood the whole thing.