Test Posit adult. Spectral analysis

In the discussion of the advantages and disadvantages of a new revolutionary floating-point format, Posit was made a statementthat Posit a task — to compactly store data, and not used in calculations; however, the calculations are performed in the arithmetic Quire with greater accuracy, which is also a standard Posit.

Well, store so store. What does it mean to “store” the numbers after the calculations performed with greater accuracy than the storage format? It means to round off and rounding means to make errors. Error can be assessed in different ways — and not to be repeated, we use the spectral analysis using the Fourier transform.

A very short introduction

If you take a signal in the form of a sine wave and perform an Fourier transform, the spectrum we must obtain a single peak; in fact the spectrum may be present as harmonics of frequency multiple of the base frequency resulting from nonlinear distortions and noise obtained as a result of noise, interference and capture. Here the level of these noises and we will measure.

Beginning

To make it even more interesting, as a test signal we will take more than one sine wave, but several; it is necessary to ensure that the periods of these sinusoids evenly within the period of discrete Fourier transform. In Wolfram Mathematica it can be done, for example:

sz = 8192;
data = Table[2 Sum[
Sin[Prime[j] k 2 Pi/sz + j*j]/sz
{j, 100, 200, 2}] // N
{k, 0, sz - 1}];

Prime numbers are used for irregular decimation frequency; and j*j shifts the phase of the sine wave depending on frequency in order to avoid strong emission in the test signal, providing it with a more or less uniform amplitude. Visually, the received signal looks like this:

Next, we nimirum it to the unit by the maximum value, and then converted to an integer 32-bit Int, Float, and Posit again to Double. If the authors are correct, then the error introduced by the conversion of the Double→Posit→Double will be closer to Double than Float.

The noise level will be analyzed in the standard signal processing units — decibels, allowing you to compare the value in the logarithmic scale. As a tool I used my own spectrum analyzer when something is written for research purposes.

comparison table

So:

blue Float
red is Posit
purple — Int32
blue — Double

Posit, of course, was a little better Float — but to the level of Double is far from it. And worse Int32! Makes sense, because part a bit it takes on the order… Let’s use this order will increase the amplitude of our signal to 1000:

Suddenly (and in fact quite expected) noise from the Float and Posit equal. Go ahead — increase the amplitude to a billion:

Float shows the same level, and Posit begins to lag. A further increase in the amplitude (10 to15) leads to a further increase in noise shelf:

Conclusion

The spectral analysis could not confirm the authors ‘ claims that the use of the format Posit as storage can provide the accuracy close to Double. Even in the best conditions the noise from the Posit was only 20 dB below the Float but above the Int32 to 10 decibels, and higher Double — 60 decibels.

In this Posit-I might find useful as protection from out of range, when emissions significantly exceed normal value, will not lead to clipping or overflow. But even in such scenarios Posit acts more like a compromise between Int32 and Float, and not by far the best format of numbers.

Source

Leave a Reply

Your email address will not be published. Required fields are marked *