Subject: Re: [xsl] Is this the best way to compute a sigmoid function? From: "Michael Kay mike@xxxxxxxxxxxx" <xsllistservice@xxxxxxxxxxxxxxxxxxxxxx> Date: Sat, 2 May 2020 21:33:58 0000 
It's a long time (almost 50 years!) since I studied numerical methods as an undergraduate, and while David Wheeler could be an incredibly boring lecturer, I do recall him demonstrating how repetitive numerical calculations could lose precision at an alarming rate. So the reason we calculate to 15 digits is not that we need 15 digits in the final answer, but rather because the errors accumulate, so if we want 5 digits in the final answer, we may need 15 digits in the intermediate steps. Michael Kay Saxonica > On 2 May 2020, at 21:53, John Lumley john.lumley@xxxxxxxxxxxxxx <xsllistservice@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > o;?Apart from determining the value of G or the fine constant, or a few other esoteric determination of funadamental constants, what practical issues require more than 78 significant figures of precision? > > Yes, some interplanetary differentials might at times. (Our moon recedes from us as fast as your fingernails grow, and GPS internals can need subnanosecond differential time intervals) but what ones we might encounter in the XML world. > > o;?The bfetishb of chasing decimal places in most, but not all, cases shows a lack of understanding of the essence of the problem. > > The (artificial) epitome of this is the welltrodden problem of a railway around the world that must be lifted up 1 cm, but stays circular... how much more rail is needed? > bWhere angels fear to treadb rush in with finding the difference by > 2*pi*6,357,000.01  2*pi*6,357,000 > which requires 910 places of numerical precision (i.e. approaching 30 bits of mantissa) neglecting the deeper structure of the mathematics.. > > John Lumley > john@xxxxxxxxxxxxxx > >> On 2 May 2020, at 19:09, Michael Kay mike@xxxxxxxxxxxx <xsllistservice@xxxxxxxxxxxxxxxxxxxxxx> wrote: >> >> o;? >> >>> On 2 May 2020, at 18:55, Costello, Roger L. costello@xxxxxxxxx <mailto:costello@xxxxxxxxx> <xsllistservice@xxxxxxxxxxxxxxxxxxxxxx <mailto:xsllistservice@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 $etotheminusxpower 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 doubleprecision floating point by whatever underlying library is used. >> >> Michael Kay >> Saxonica >> XSLList info and archive <http://www.mulberrytech.com/xsl/xsllist> >> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsllist/949522> (by email <applewebdata://2896573D12DF4038BCB17D3643583865>) > > XSLList info and archive <http://www.mulberrytech.com/xsl/xsllist> > EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsllist/293509> (by email <>)
Current Thread 


< Previous  Index  Next > 

Re: [xsl] Is this the best way to, John Lumley john.lum  Thread  Re: [xsl] Is this the best way to c, John Lumley john@xxx 
Re: [xsl] Is this the best way to, John Lumley john.lum  Date  Re: [xsl] Is this the best way to c, John Lumley john@xxx 
Month 