Error function

84 views
Skip to first unread message

Oliver Ruebenacker

unread,
Apr 22, 2013, 9:32:36 AM4/22/13
to scala-user

     Hello,

  Is the error function implemented somewhere in the standard Scala libraries?

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

  Thanks!

     Take care
     Oliver

--
IT Project Lead at PanGenX (http://www.pangenx.com)
The purpose is always improvement

Simon Ochsenreither

unread,
Apr 22, 2013, 10:31:49 AM4/22/13
to scala...@googlegroups.com
Hi Oliver,

no, but you might have a chance to find it in the various math libraries for Scala. Otherwise, you could also implement it yourself and contribute the code!

Be,

Simon

Oliver Ruebenacker

unread,
Apr 22, 2013, 10:45:42 AM4/22/13
to Simon Ochsenreither, scala...@googlegroups.com

     Hello,

  There's a formula on Wikipedia with maximum error of 1.2e-7, which I think may be sufficient for my purpose, but not for a Scala standard library. Does any one have a better formula?

  Thanks!

     Take care
     Oliver


--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jason Zaugg

unread,
Apr 22, 2013, 12:27:15 PM4/22/13
to Oliver Ruebenacker, Simon Ochsenreither, scala-user
I would recommend to use Apache Commons Math:

> set libraryDependencies += "org.apache.commons" % "commons-math3" % "3.2"
[info] Defining root/*:library-dependencies
[info] The new value will be used by root/*:all-dependencies
[info] Reapplying settings...
[info] Set current project to root (in build file:/Users/jason/code/scratch1/)
> console-quick
[info] Updating {file:/Users/jason/code/scratch1/}root...
[info] Resolving org.apache.commons#commons-math3;3.2 ...
[info] Done updating.
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_37).
Type in expressions to have them evaluated.
Type :help for more information.

scala> org.apache.commons.math3.special.Erf.erf(1.2)
res0: Double = 0.9103139782296353

-jason

Rex Kerr

unread,
Apr 22, 2013, 1:16:14 PM4/22/13
to Jason Zaugg, Oliver Ruebenacker, Simon Ochsenreither, scala-user
I'd also recommend using Apache Commons Math.

I have an implementation that is about 10x faster and just as accurate, but I'm not yet ready to release it as it's part of a larger package that still requires work.  If you really require speed, I can consider releasing just this under some appropriate license.  (Whatever that means for code that is essentially, "I typed up some math in a programming language".)

  --Rex
Reply all
Reply to author
Forward
0 new messages