Subject: Re: [xsl] Is this the best way to compute a sigmoid function? From: "Martin Honnen martin.honnen@xxxxxx" <xsllistservice@xxxxxxxxxxxxxxxxxxxxxx> Date: Sat, 2 May 2020 18:00:52 0000 
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)
Does your environment not support https://www.w3.org/TR/xpathfunctions/#funcmathexp?
as="xs:decimal" />
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:calltemplate name="exp"> <xsl:withparam name="pX" select="$x" /> </xsl:calltemplate> </xsl:function>
Then I computed the sigmoid function this way:
<xsl:variable name="etotheminusxpower" select="f:e($x)"
<xsl:valueof select="1 div (1 + $etotheminusxpower)"/>
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 $etotheminusxpower I specified it this way: as="xs:decimal". Should I have specified it this way: as="xs:float" instead? Would that yield better/moreaccurate/morereliable/morewhatever results?
Any suggestions you might have would be greatly appreciated.
/Roger
Current Thread 


< Previous  Index  Next > 

[xsl] Is this the best way to compu, Costello, Roger L. c  Thread  Re: [xsl] Is this the best way to c, Michael Kay mike@xxx 
[xsl] Is this the best way to compu, Costello, Roger L. c  Date  Re: [xsl] Is this the best way to c, Michael Kay mike@xxx 
Month 