# Uncertainty Hexadecimal (“Ux”) Data Format

## Introduction

The Signaloid Uncertainty Hexadecimal data format is a digital representation for complete probability distributions. You can think of each Signaloid Ux number as representing a complete histogram of values.

Traditional computing platforms take integer and floating-point values as inputs and perform operations (e.g., **ADD**, **SUBSTRACT**, **MULTIPLY**, **XOR**, etc.) on these data. The results of these operations are other integers or floating-point values.

The Signaloid Cloud Compute Engine can take in as input the same kinds of integer and floating-point values and perform the same kinds of operations (e.g., **ADD**, **SUBSTRACT**, **MULTIPLY**, **XOR**, etc.). In addition to these capabilities of traditional computing platforms, Signaloid C0 uncertainty-tracking cores allow its users to optionally associate additional information about (potentially-different) probability distributions, with each individual input value. Then, when performing arithmetic operations such as those listed above, it simultaneously also performs distribution arithmetic on any associated probability distributions and generates the appropriate probability distribution to associate with the arithmetic operation’s result. The Signaloid Cloud Compute Engine also enables several valuable operations that act on distribution information, such as performing Bayesian inference or creating empirical probability distributions from data, e.g., using `UxHwDoubleDistFromSamples`

.

*Ux Data* is a new way to represent uncertainty information (probability distributions) in a way that is data-efficient and makes computations on distributions also efficient. It exploits the mathematics of probability distributions to make possible uncertainty quantification that avoids the false choice between speed and correctness and sidesteps the challenges of convergence faced by traditional iterative uncertainty quantification such as Monte Carlo methods. With Ux Data representations, computing systems no longer need to make the false choice between speed (time to reach an answer) and convergence (e.g., how many standard deviations out from the expected value the uncertainty quantification has sampled, e.g., 3-sigma or 6-sigma).

## Why Ux Data Exists and What It Contains

If you've used `fprintf()`

of a floating-point value into a file using the Signaloid Cloud Developer Platform, you might have come across a string like this:

`0.785398Ux0400000000000000003FE921FB54442D18000000013FE921FB54442D188000000000000000`

These strings begin with a number (**0.785398** in this example), followed by the characters “**Ux**”, followed by a hexadecimal string. They are an instance of uncertainty hexadecimal data or "Ux Data”. We stylize this in initial capitals as we treat it as a proper noun. In the form of the example above, we refer such Ux Data as "Ux Strings". Ux Strings contain both traditional (point-valued or particle) numerical information (0.785398) as well as uncertainty distribution information associated with that value (0400...0000). The distribution information is a new representation, developed by Signaloid, which exploits knowledge of the mathematics behind Signaloid's efficient uncertainty-tracking computation methods to represent arbitrary empirical distributions. At the same time, it takes advantage of knowledge of the analytic form of the probability density function in the case of analytic distributions.

We use the term *Ux Data* to refer to the general form of this information and use the more specific term *Ux String* to refer to the ASCII-formatted version of the data (we use the term *Ux Binary* to refer to the binary representation of the information). The following sections of this overview describe these string and binary formats in more detail.

## The Format of Ux Data: Ux Binary and Ux Hexadecimal Strings

There are therefore two forms in which Ux Data might appear inline in a data stream (there are other ways in which distribution information can be stored and transmitted).

At the level of binary representation, the format of Ux Binary data is:

- "Ux" (2 ASCII characters).
- Representation type (8 bits).
- Number of samples (64 bits).
- Mean value of distribution (64 bits).
- Number of non-zero mass Dirac deltas (32 bits).
- A sequence of n pairs of (a) support position (64 bits); (b) probability mass (64 bits).

When we represent Ux Data as ASCII strings, the format, which we refer to as Ux Strings, is:

- "Ux" (2 ASCII characters).
- Representation type (hexadecimal value as 2 ASCII characters).
- Number of samples (hexadecimal value as 16 ASCII characters).
- Mean value of distribution (hexadecimal value as 16 ASCII characters).
- Number of non-zero mass Dirac deltas (hexadecimal value as 8 ASCII characters).
- A sequence of n pairs of (a) support position (hexadecimal value as 16 ASCII characters); (b) probability mass (hexadecimal value as 16 ASCII characters).

## ✏️ Example of storing a Ux string

The following simple code example shows a distribution representing the uncertainty of a variable `value`

whose samples are stored in the `samples`

array. The simple example runs on the Signaloid C0 processor and uses the capabilities exposed above the ISA to inject distribution information into the processor, i.e., using `UxHwDoubleDistFromSamples`

. The example assumes that you have mounted your Signaloid Cloud Storage at `sd0`

. You can read the reference of the Code Editor for detailed steps on how to mount your Signaloid Cloud Storage. The example opens the `uxString.txt`

file and stores the distributional information of `value`

encoded as a Ux string. Figure 1 shows the visualization of the distribution of the variable `value`

. The Ux String and binary digits that follow below show the representation of that distribution as hexadecimal and binary formatted uncertainty information in Signaloid’s uncertainty data format. Figure 2 shows the contents of the `uxString.txt`

file as they appear in the Signaloid Cloud Data Storage in the Data and Sensors page.

`#include <stdio.h>`

#include <uxhw.h>

int

main(void)

{

FILE * fp;

double value, samples[] = {90, 120, 96, 20, 99, 102, 112, 68, 90, 109};

value = UxHwDoubleDistFromSamples(samples, sizeof(samples)/sizeof(double));

fp = fopen("sd0/uxString.txt", "w+");

fprintf(fp, "value = %lf\n", value);

printf("value = %lf\n", value);

return 0;

}

**Figure 1.**The distribution representing the uncertainty of the variable

`value`

whose samples are stored in the `samples`

array. The simple code example runs on the Signaloid C0 processor and uses the `UxHwDoubleDistFromSamples`

to initialize the uncertainty of the variable `value`

.Ux String representing the distribution of the variable `value`

(including particle value prefix):

`90.600000Ux04000000000000000A4056A666666666670000000A40568000000000000CCCCCCCCCCCCCCD405E0000000000000CCCCCCCCCCCCCCD40580000000000000CCCCCCCCCCCCCCD40340000000000000CCCCCCCCCCCCCCD4058C000000000000CCCCCCCCCCCCCCD40598000000000000CCCCCCCCCCCCCCD405C0000000000000CCCCCCCCCCCCCCD40510000000000000CCCCCCCCCCCCCCD40568000000000000CCCCCCCCCCCCCCC405B4000000000000CCCCCCCCCCCCCCC`

## Ux Binary representing the distribution of the variable "value" (excluding particle value prefix and "Ux"):

`00000100000000000000000000000000000000000000000000000000000000000000101001000000010101101010011001100110011001100110011001100110011001110000000000000000000000000000101001000000010101101000000000000000000000000000000000000000000000000000110011001100110011001100110011001100110011001100110011001101010000000101111000000000000000000000000000000000000000000000000000001100110011001100110011001100110011001100110011001100110011010100000001011000000000000000000000000000000000000000000000000000000011001100110011001100110011001100110011001100110011001100110101000000001101000000000000000000000000000000000000000000000000000000110011001100110011001100110011001100110011001100110011001101010000000101100011000000000000000000000000000000000000000000000000001100110011001100110011001100110011001100110011001100110011010100000001011001100000000000000000000000000000000000000000000000000011001100110011001100110011001100110011001100110011001100110101000000010111000000000000000000000000000000000000000000000000000000110011001100110011001100110011001100110011001100110011001101010000000101000100000000000000000000000000000000000000000000000000001100110011001100110011001100110011001100110011001100110011010100000001010110100000000000000000000000000000000000000000000000000011001100110011001100110011001100110011001100110011001100110001000000010110110100000000000000000000000000000000000000000000000000110011001100110011001100110011001100110011001100110011001100`

**Figure 2.**The code example stored the distributional information of variable

`value`

encoded as a Ux String in the file `uxString.txt`

in the Signaloid Cloud Data Storage. You can see the contents of the `uxString.txt`

file as they appear in the Signaloid Cloud Data Storage in the Data and Sensors page.## ✏️ Example of ingesting a Ux string

The simple program shown below reads in the Ux String using the standard C library call `sscanf`

, and by doing so, injects distribution
information encoded as a Ux String into the variable `value`

when executed on the Signaloid C0 processor.

`#include <stdio.h>`

int

main(void)

{

double value;

sscanf("90.600000Ux04000000000000000A4056A666666666670000000A40568000000000000CCCCCCCCCCCCCCD405E0000000000000CCCCCCCCCCCCCCD40580000000000000CCCCCCCCCCCCCCD40340000000000000CCCCCCCCCCCCCCD4058C000000000000CCCCCCCCCCCCCCD40598000000000000CCCCCCCCCCCCCCD405C0000000000000CCCCCCCCCCCCCCD40510000000000000CCCCCCCCCCCCCCD40568000000000000CCCCCCCCCCCCCCC405B4000000000000CCCCCCCCCCCCCCC", "%lf", &value);

printf("value = %lf\n", value);

return 0;

}