Any way to do asymmetric tolerances in Julia?

Hello!

Suppose I have:

LowerTolerance = 1
UpperTolerance = 3

Could I then have an assymmetric tolerance such that if I have a value of x = 10, its lower bound would be 9 and upper bound 13?

Measurements.jl seems incapable of this, if true, I am looking for another way.

Kind regards

In what context do you want to do this?

If it is for optimization, many packages will allow you to set upper and lower bounds on variables to be whatever you want.

If you want to impose a constraint on a variable during the running of some program, it is better to simply do runtime checks the first time you need this constraint, e.g. in a function add a check like 9 <= x <= 13 || throw(ArgumentError("x = $x is out of bounds")). See also Defining a new type with constraints on values

Measurements.jl seems incapable of this, if true, I am looking for another way.

Measurements.jl is for propagating uncertainties, and it inherently assumes that the uncertainties are normally distributed statistical quantities and that it only needs to track/propagate the mean and stddev.

If you have some other statistical distribution on x, and you are passing it through some calculation and you want to compute the distribution of the output, that’s a much more complicated problem. You may want something like MonteCarloMeasurements.jl in that case.

Hi,

So I want to do it because I just would like to be able to assign values in a DataFrame some lower and upper tolerance bounds, imagine you are doing like a circle and you want to specify its max and min diameter - so not an uncertainity/measurement as such.

Kind regards

Why not just check the values when the DataFrame is created? What are you trying to accomplish that a one-time check won’t satisfy?

Check also UncertainData.jl out.