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

Is this the best way to compute a sigmoid function?

Subject: Is this the best way to compute a sigmoid function?
From: "Costello, Roger L. costello@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 2 May 2020 17:55:28 -0000
 Is this the best way to compute a sigmoid function?
Hi Folks,

I have a variable $x that has a value such as 0.6

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)

I am using the exp template in Dimitre's FXSL library.

[Dimitre, incredible library]

I created a wrapper function that simply calls Dimitre's exp template:

<xsl:function name="f:e" as="xs:decimal">
    <xsl:param name="x" as="xs:decimal" />

    <xsl:call-template name="exp">
        <xsl:with-param name="pX" select="$x" />
    </xsl:call-template>
</xsl:function>

Then I computed the sigmoid function this way:

<xsl:variable name="e-to-the-minus-x-power" select="f:e(-$x)" as="xs:decimal"
/>
<xsl:value-of select="1 div (1 + $e-to-the-minus-x-power)"/>

When $x has the value 0.6 I get this result: 0.645656306189717285

Do you see any errors in how I am computing the sigmoid function?

Is there a better way to do it? That is, one that returns more accurate
results? (However, it already appears to be mighty accurate -- look at all
those digits to the right of the decimal point) 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? Would that yield
better/more-accurate/more-reliable/more-whatever results?

Any suggestions you might have would be greatly appreciated.

/Roger

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.