Skip to content

Instantly share code, notes, and snippets.

@SeijiEmery
Last active January 30, 2017 23:19
Show Gist options
  • Select an option

  • Save SeijiEmery/d059933a168bc7e1ceedacb4a45e4aad to your computer and use it in GitHub Desktop.

Select an option

Save SeijiEmery/d059933a168bc7e1ceedacb4a45e4aad to your computer and use it in GitHub Desktop.
Significant figures + concept for lab excel replacement (had this idea floating around for a while)
Sig figs (pet peeve):
As a CS / sort-of math major, it seems like it would make much more sense to just record scientific
measurements as ranges / intervals, ie. (4.867 ± 0.0005), and treat them as algebraic pairs / 2-tuples,
with a few special rules for how the error value gets carried; a neat result would be that in exact
(infinite precision) figures the error value is zero, eg (4.25 ± 0)
Rules are quite simple, with the rule that numbers are represented by (a + be), where e is a symbolic
placeholder like i, and defined such that e^n = e^m for all n, m ≠ 0. (ie. e propagates, but e^2 = e = e^-1, etc).
So,
(a + be) + (c + de) = (a + c) + (b + d)e
(a + be) * (c + de) = (ac + bce + ade + bde) = (ac) + (bc + ad + bd)e
etc...
Using sig. figures => error range notation,
4.867 + 2.23 = (4.867 ± 0.0005) + (2.23 ± 0.005)
= (7.097 ± 0.0055)
= 7.10, rounded + converted back to standard scientific notation
(but that error value will stay MUCH more accurate for any calculation w/ a large number of operations;
the standard scientific practice of solving equations using variables, then calculating values using max
precision + rounding at the end is equivalent to this method)
Obviously, doing hand calculations with this sort of system would be a PITA (but could be sort of elegant
by representing numbers on two lines like this, for example (eg. 4.867 x 10**16) – could just align or draw
a box around them or something, and would have space for full units at the end
| 4.867 e16 m <----- pretend there's a division bar between 'm' and 's'
| 0.0005 e16 s
The best solution would be to build an excel-like data entry + manipulation tool, which would do all
calculations and thus eliminate the potential for human error.
Let me know if such a thing exists. If it doesn't (or the existing options are all shitty), and if I had the
time and inclination to build such a thing, I'd probably focus on building a GUI shell and table editing
abilities (with really good, user-friendly UI) on top of python numerics libraries (numpy, sympy, etc; could
build the user interface in pyqt and save to a user-readable text format (and allow import / selective export
to/from .xlsx and .csv ofc)
This hypothetical application would ideally need to have the following features:
– Builtin support for the interval / error value concept described above and scientific notation
– Display + edit arbitrary python data types, ideally extensible with plugins
– All operations implemented as python functions, so write your own + do whatever
– Support for N-dimensional tables (unlike excel)
– Several main table operations across a single axis / all elements: map / reduce / filter / sort, with either
existing operations or a python closure (with nicer syntax: not writing a def() statement, and input variables
are hardcoded with specific names). Results get inserted into new tables, which can have labels etc
– Tables can also be treated as n-dimensional matrices; internal implementation will probably be that (numpy)
– MVC-based architecture
– All tables + values have unique names; a worksheet model is just a flat dict with python objects
– "Tables" implemented as views into this data; can slice a 3-4 dimensional array into navigable 2d views
for instance, or grab tagged labels / columns, etc.
– Would be tempting to compare this to SQL; similar but NO, not using sql / any of that mess for this
– Neat, b/c data export to / from excel + csv can also be implemented as views, and can directly control
formatting of data to match specific formats, and independently of in-app views
– Could be called labkit or something.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment