Coder Social home page Coder Social logo

Comments (10)

adamslc avatar adamslc commented on May 9, 2024

I've started working on this a little bit, but I'm not sure how we should handle this when the user provides more than two significant digits. I think it would be very confusing and frustrating for a new user if they entered 1.234 ± 0.05678, and the REPL responded with 1.234 ± 0.057 (regardless of the statistical validity of using that precise of an uncertainty). One option would be to leave show() alone, and instead rewrite showcompact() to round the error at two significant figures, but this would still leave a lot of undesirably long output.

from measurements.jl.

giordano avatar giordano commented on May 9, 2024

Actually I'm also unsure how to handle this feature and I'd like suggestions from users on this.

A possibility could be not to overload show but rather provide a new function to pretty print the object according to user needs. This may be useful when one wants to form a string out of the result of calculations.

from measurements.jl.

ggggggggg avatar ggggggggg commented on May 9, 2024

I think it would be reasonable to show 2 digits of uncertainty, and same rounding on the value in all cases. Just be sure to explain in the documentation.

MATLAB truncates floating point number for display by default. This will be much less confusing that MATLAB's behavior.You have a well principled choice to guide your truncation. http://www.mathworks.com/help/matlab/ref/format.html

You could provide ways to get the full set of digits Then provide a way to get the full representation easily. Maybe a function showfull that prints all the digits. Or a Module level setting Measurements.set_show_format(Measurements.ALLDIGITS).

from measurements.jl.

JulienKluge avatar JulienKluge commented on May 9, 2024

So, to relive the conversation on that, the next Mathematica will come out with inbuilt uncertainty propagation and Stephen Wolframs livestreams some of its design decisions. So, let's learn from the big players. You can view this streams:
here: https://www.youtube.com/watch?v=a1UZ07e8-s8
and some of it here: https://www.youtube.com/watch?v=--iBBCklEIQ

They went with a convention often used in physics which is rounding to the first significant digit except it being 1 or 2, then round to two significant digits.
I'd propose we also go with this although i share the worries of @adamslc . However, we can address this with two things:

  • Provide a "Measurement-Rounding" function which supports full precision and other styles (I could write one and make a pull request)
  • Make this fact (especially how to get full precision) a prominent example in the Readme and the docs.

from measurements.jl.

JulienKluge avatar JulienKluge commented on May 9, 2024

btw. this would mean that:
(1.2 ± 0.3) + (4.5 ± 0.6) ==> (5.7 ± 0.7)
but
(1.2 ± 0.15) + (4.5 ± 0.2) ==> (5.70 ± 0.25)
and especially the edge case:
(1.2 ± 0.16) + (4.5 ± 0.25) ==> (5.70 ± 0.30)

from measurements.jl.

giordano avatar giordano commented on May 9, 2024

Thanks for reviving this issue and sharing the videos! I didn't know mathematica was going to introduce this feature. I'd like to know more about how they implemented this, is this covered in those videos?

I can see the point of the 2-digits-only-with-1-and-2 convention, but I've never been sold on it, I usually prefer to always read 2 digits on the uncertainty.

I also want to stress that this is just for printing the number, which will actually retain the full information about the uncertainty.

from measurements.jl.

JulienKluge avatar JulienKluge commented on May 9, 2024

Well there is an even earlier stream (which i currently can't find) where they discuss it a bit. But this was all preliminary as far as I can tell so take this with a grain of salt. They went with standard operations always being independent. The way of tracking all covariances, like this package does, was discussed but discarded due to the cluttering issue when many variables come into play.
So they went with introducing an auxiliary function for doing depended error propagations. This plays nicely with Mathematica since it can be done symbolically. This isn't as easy to use as Measurements.jl but introduces the nice ability to propagate whole covariance matrices.

Well, I've seen the always-2-digits convention too, although more rarely (often in physical constants with the "brace-notation" like (5.70 ± 0.25) => 5.70(25) ).
However, I'd be fine with this since it allows for easy converting to the 1-digit form in my head anyways and isn't unusual or so.

from measurements.jl.

giordano avatar giordano commented on May 9, 2024

The way of tracking all covariances, like this package does, was discussed but discarded due to the cluttering issue when many variables come into play.

Yes, I'm aware of this issue. With few variables this package is really fast, it comes into troubles with many of them as the cost of computation is O(n^2)

from measurements.jl.

BeastyBlacksmith avatar BeastyBlacksmith commented on May 9, 2024

As far as I understood the canonical way would be to have

print( IOContext(io, :compact => false), number ) # gives all digits
print( IOContext(io, :compact => true), number ) # gives rounded/ truncated result

I'll make a PR where one can explore this feature.

from measurements.jl.

giordano avatar giordano commented on May 9, 2024

Ok, this should be fixed by 0a44e6f...95087d7. Thanks to @BeastyBlacksmith for starting this!

from measurements.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.