Giter Site home page Giter Site logo

pdground's Introduction

Gem Version

PDGRound

PDGRound allows you to round a number with an uncertainty using the PDG rounding rules.

Installation

Add this line to your application's Gemfile:

gem 'pdground'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pdground

Usage

Pdground provides an easy to use function to round a given number with an uncertainty using the PDG rules. The rule states the following [Sec 5.3]:

The basic rule states that if the three highest order digits of the error lie between 100 and 354, we round to two significant digits. If they lie between 355 and 949, we round to one significant digit. Finally, if they lie between 950 and 999, we round up to 1000 and keep two significant digits. In all cases, the central value is given with a precision that matches that of the error

For example, given the value 12.2135 +- 0.03215 the rounded value reults in 12.214 +- 0.032 while for the value 12.2135 +- 0.06515 the rounded value reults in 12.21 +- 0.07.

Using Pdground in your code it is as simple as doing:

require 'pdground'

value = 12.2135
error = 0.06515
result = PDGRound.round(meas: value, unc: error)
puts "Rounded value: #{result[0]}"
puts "Rounded error: #{result[1]}"
# Rounded value: 12.21
# Rounded error: 0.07 

Contributing

Contributions to this project are only accepted in its GitLab repo If you want to contribute to improve this gem with any bug fix or new feature:

  • First open an issue to discuss the bug or feature
  • Place a merge request referring to the issue once agreed to include it

Tests must be added to ensure maintainability.

License

The gem is available as open source under the terms of the MIT License.

pdground's People

Contributors

aarakke avatar

Stargazers

Philipp Bielefeldt avatar EVOKE avatar

Watchers

James Cloos avatar  avatar

pdground's Issues

Bug: Precision of mean value doesn't match the error's

There are two cases I spotted, where the rounding doesn't correspond to what pdg requires:

  • 4.0048 \pm 0.1072 should be rounded to 4.00 \pm 0.11, but it becomes 4.0 \pm 0.11. This only happens when the mean value would have a 0 at the end.

  • 202.18 \pm 20.16 is rounded to 200 \pm 20 instead of 202 \pm 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.