-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
new ufloat_from_sample function #276
Comments
I'm not sure if this should be added to uncertainties or not. I see that it is convenient, and I would indeed use it. But I don't know that It's also important to note that this function only really works if the sample data are normally distributed. It could and would get used for non-normally distributed data and might lead to wrong or at least biased conclusions. At the very least this caution needs to be documented and maybe appear in the function name or something.
compared to
Is this convenience function really needed as more code to maintain in My concerns are that there could be a slippery slope towards adding many such convenience functions, increasing the maintenance burden. I would consider myself -0 on this right now. |
@Myles244 @jagerber48 I agree with @jagerber48. This function would provide one of potentially many approaches to converting a collection of values into a I would not be opposed to having a module that supported such conversions of values to |
I think that's enough of a reason to include it in uncertaintes.
In which case we should decide where such functions should go. I agree |
I originally included the function in
I agree the assumptions of the function could be more explicit, perhaps
If it would be better for the function to be more general, then |
I like a plain function named My main concern would be what inputs we would be supporting. Uncertainties does not require Numpy, so it should handle a plain list of numbers without Numpy or Scipy installed, and "no Numpy installed" should be handled gracefully. I imagine someone will expect it to "just work" with a Pandas Series, too. And maybe xarray, and others. Maybe that can be handled with: if Numpy is available and the value is not a list or a ndarray, it should assume that the object has a Also: if someone gives a multi-dimensional array, should that take an Really, not trying to make it more complicated, just pointing out the inherent complications of the idea ;). |
Yea the optional method is a nice idea. Where would you place the function
`ufloat_from_sample`?
The PR uses numpy but could be changed to use math or raise an error if
numpy isn't available.
I suspect using numpy allows this function to work for pandas or xarray.
Most objects from other libraries have support for numpy so `np.mean(obj)`
returns a float.
Writing functions to accept *any* input from the get go is unreasonable.
People are free to submit PRs adding support if they want support for a
library. I think it's reasonable PRs should work with lists and numpy
arrays at a minimum.
…On Fri, 20 Dec 2024, 19:06 Matt Newville, ***@***.***> wrote:
I like a plain function named ufloat_from_samples (or ufloat_from_sample),
though Ufloat.from_samples would be okay too. I also like the idea of
optional methods, defaulting to Gaussian, though supporting the options
might be some work.....
My main concern would be what inputs we would be supporting. Uncertainties
does not require Numpy, so it should handle a plain list of numbers without
Numpy or Scipy installed, and "no Numpy installed" should be handled
gracefully. I imagine someone will expect it to "just work" with a Pandas
Series, too. And maybe xarray, and others.
Maybe that can be handled with: if Numpy is available and the value is not
a list or a ndarray, it should assume that the object has a to_numpy()
method and use that?
Also: if someone gives a multi-dimensional array, should that take an axis
argument to sample along that axis?
Really, not trying to make it more complicated, just pointing out the
inherent complications of the idea ;).
—
Reply to this email directly, view it on GitHub
<#276 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADEMLECFBFXTIUGAY7BOLQT2GRTCPAVCNFSM6AAAAABTWVACMWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNJXGU3TANBTGI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I am unsure of the proper place for this function. So I have moved into I have now made the following changes to the pull request: -The function I ran into some circular import errors while trying to generate uarrays when handling n-D arrays, so I duplicated some of the code inside If there are any other common ways to extract ufloats from a sample of measurements, I'm happy to add them as options. |
Hello, I often use this package to analyse data from experiments, and I usually have a list of measurements of a variable. These measurements are usually normally distributed. So I combine them using the mean as the true value and the sample standard deviation divided by the square root of the number of measurements as the standard deviation of the mean. Something like this:
value=ufloat(numpy.mean(sample),numpy.std(sample,ddof=1)/numpy.sqrt(len(sample)))
In an attempt to save myself and hopefully a few others some time, would it be suitable to add a function
uncertainties.unumpy.ufloat_from_sample()
ps I'm new to contributing to open source so if I've made any faux pas, I'm sorry.
The text was updated successfully, but these errors were encountered: