Go to the first, previous, next, last section, table of contents.


3.4 Numerical Values

LIBPA provides three ways to represent extremely small numerical values, such as are commonly encountered in statistical modeling applications: balanced_t, L_t, and logpr_t. The pr_t module provides a generic macro interface to all three modules. The three modules offer a wide range of performance/accuracy tradeoffs. L_t is the fastest and requires the least memory. logpr_t is the most accurate but the slowest. balanced_t is nearly as accurate as logpr_t and can be significantly faster on systems with a slow `libm.a' math library, such as SunOS and HP-UX.

The balanced_t type represents single precision floating point numbers with extended 32-bit exponents. As a result, the balanced_t module supports floating point arithmetic for extremely small and extremely large numerical values -- values which would cause overflow or underflow in double precision floating point arithmetic. Depending on your machine, balanced_t arithmetic is from 10 to 20 times slower than double precision floating point arithmetic and is only slightly less accurate that single precision floating point arithmetic. Unlike the other LIBPA numerical types, the balanced_t type can represent a large range of numbers, such as very large positive numbers and negative numbers.

The L_t type represents probability values using fixed point numbers -- char, short, int, and long --- where larger types are capable of representing ever-smaller probability values. Depending on your machine, L_t arithmetic is from 1.2 to 1.8 times slower than double precision floating point arithmetic. It is also considerably less accurate. balanced_t arithmetic is more accurate than L_t arithmetic, but is more than five times slower and typically requires at least twice as much memory to represent each probability value.

Finally, we also provide a standard logpr_t type for the logarithmic representation of probability values using double-precision floating point numbers. Although this is the most accurate representation of probability values, it is also the slowest. Depending on the math libraries provided by your operating system, logpr_t arithmetic can be 13 to 60 times slower than double precision floating point arithmetic.

The following table reports timing results of the `pr.bench' benchmark on four different machines. All numbers are user times in seconds on an unloaded machine, as reported by /usr/bin/time or /usr/bin/timex (lower is better).

                        double   logpr_t   balanced_t   L_t
                        ------   -------   ----------  -----
AlphaStation 500/500    121.8     1619.8    1292.7     207.2
Sun Ultra2 1200         301.2    10166.4    5037.2     541.9
SGI O2 180mhz           371.4     8570.8    4830.1     546.6
HP 9000/755             369.2    19643.6    7497.1     638.0
Dell GXM 5166           805.5    12010.6    5118.6     933.3


Go to the first, previous, next, last section, table of contents.