Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support correlation between variables #3

Closed
giordano opened this issue Jun 9, 2016 · 1 comment
Closed

Support correlation between variables #3

giordano opened this issue Jun 9, 2016 · 1 comment
Assignees

Comments

@giordano
Copy link
Member

giordano commented Jun 9, 2016

Currently,

using Measurements
x = 5.2 ± 0.4
x-x != zero(x)
x*x != x^2
tan(x) != sin(x)/cos(x)

because the package doesn't support correlation between variables.

I don't really know how the covariance matrix should be calculated in this case, where there are two single measurements, not two elements of a population. Any hint on this is appreciated.

After looking at the user guide of the Python package uncertainties, I think that the Measurement type should be extended to have two extra fields: a unique tag to identify each measurement (so that two measurement with the same value and uncertainty are equal), and the list of derivatives of variables constituting the object. For example:

# Definition.  The Measurement type is composed by the following fields:
#   * val: the nominal value of the measurement
#   * err: the uncertainty, assumed to be standard deviation
#   * tag: a (hopefully) unique identifier, it is used to identify a specific
#     measurement in the list of derivatives.
#   * der: the list of derivates.  It is a dictionary, whose keys are the tags
#     of the quantities with which the measurement has been derived, and the
#     corresponding value is the derivative of the new measurement with respect
#     to that measurement.  This dictionary is useful to trace the contribution
#     of each measurement.
immutable Measurement{T<:Real} <: Real
    val::T
    err::T
    tag::Float64
    der::Dict{Float64, T}
end

# Constructor
function Measurement(val::Real, err::Real)
    val, err, der = promote(val, err, one(val))
    tag = rand()
    return Measurement(val, err, tag, Dict(tag=>der))
end

This change, necessary to make the package fully work, will definitely degrade performance, so it needs to be thought carefully. Input is very welcome.

giordano added a commit that referenced this issue Jun 14, 2016
Performance is less than optimal (but should be better in Julia 0.5),
for the time being I try to implement the algorithm to support
correlation, then I’ll try to smooth the rough edges off.

See issue #3.
giordano added a commit that referenced this issue Jun 15, 2016
The task outlined in issue #3 (support for correlation between varibles)
is complete, but performance should be improved in order to make this
feature more usable.
@giordano
Copy link
Member Author

This has been implemented in commits 6f8fb48...590d423 (from 6f8fb48 Move @uncertain to math.jl file to 590d423 10x improvement for "result" function for more than one argument; see 6f8fb48...590d423)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant