[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Is this the best way to compute a sigmoid function

Subject: Re: Is this the best way to compute a sigmoid function?
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 2 May 2020 18:09:19 -0000
Re:  Is this the best way to compute a sigmoid function
> On 2 May 2020, at 18:55, Costello, Roger L. costello@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>
> I want to compute the result of evaluating this sigmoid function:
>
>     1
> ----------------
> (1 + e**-x)
>
> That is, compute 1 divided by (1 + e raised to the -x power)

In recent versions of XPath, you can simply do

(1 div (1 + math:exp(-$x)))

> (However, it already appears to be mighty accurate -- look at all those
digits to the right of the decimal point)

I hope you don't seriously believe that precision implies accuracy - that
someone who claims the population of the world is 7,345,651,523 is more likely
to be right than someone who says it is 7 billion.

> Notice that for the variable $e-to-the-minus-x-power I specified it this
way: as="xs:decimal". Should I have specified it this way: as="xs:float"
instead?

For calculations like this it's best to use xs:double. You don't need any more
precision than this, and exponential/trigonometric functions are likely to be
implemented as double-precision floating point by whatever underlying library
is used.

Michael Kay
Saxonica

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.