From 314c32da2033437e1b57db78d3c5f87379dd327f Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:38:43 +0000 Subject: [PATCH 01/21] Update core.py --- uncertainties/unumpy/core.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/uncertainties/unumpy/core.py b/uncertainties/unumpy/core.py index 763f57d9..e2eb47cb 100644 --- a/uncertainties/unumpy/core.py +++ b/uncertainties/unumpy/core.py @@ -119,6 +119,16 @@ class from this module) are passed through untouched (because a ############################################################################### +def ufloat_from_sample(sample): + """ + Return a ufloat where the nominal value and standard deviation are + the mean and uncertainty on the mean of the sample of values. + If a the sample is a set of random measurements of a normal distribtuion + then the returned value will contain the best estimate of the mean + and standard deviation of the distribution. + """ + return uncert_core.ufloat(numpy.mean(sample),numpy.std(sample,ddof=1)/numpy.sqrt(len(sample))) + def derivative(u, var): """ From f9ed2db3e1bf56fea143f822c65e6845b3c182a2 Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:48:36 +0000 Subject: [PATCH 02/21] Update CHANGES.rst --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index c9263ab6..237c0432 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,6 +12,7 @@ Changes time. Now such a function can be imported but if the user attempts to execute it, a `NotImplementedError` is raised indicating that the function can't be used because `numpy` couldn't be imported. +- Added unumpy.ufloat_from_sample to create a ufloat from a random sample of a variable. Fixes: From 4fba1749ab8b5cdca105554ab34804246101e27e Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:38:33 +0000 Subject: [PATCH 03/21] Update numpy_guide.rst --- doc/numpy_guide.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/numpy_guide.rst b/doc/numpy_guide.rst index f350765f..110e7152 100644 --- a/doc/numpy_guide.rst +++ b/doc/numpy_guide.rst @@ -141,6 +141,16 @@ and is not named :func:`acos` like in the :mod:`math` module). The definition of the mathematical quantities calculated by these functions is available in the documentation for :mod:`uncertainties.umath`. +.. index:: Numbers with uncertainties from samples + +Numbers with uncertainties from samples +--------------------------------------- + +Numbers with uncertainties can be found from samples of numbers +without uncertainties using :func:`ufloat_from_sample`. This is +an estimate on the true value of the number and its uncertainty, +and so it works best for large samples that are normally dristobuted. + .. index:: pair: testing and operations (in arrays); NaN From 86f8f7d3b33549a17e953a97ca53808db72c03a0 Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Thu, 19 Dec 2024 23:31:28 +0000 Subject: [PATCH 04/21] Update test_unumpy.py --- tests/test_unumpy.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_unumpy.py b/tests/test_unumpy.py index 783fd336..4974caae 100644 --- a/tests/test_unumpy.py +++ b/tests/test_unumpy.py @@ -290,6 +290,16 @@ def test_component_extraction(): assert numpy.all(unumpy.std_devs(mat) == [0.1, 0.2]) assert type(unumpy.nominal_values(mat)) == numpy.matrix +def test_ufloat_from_sample(): + "Test genarating a number with an uncertainty from a sample" + + test_sample=[-1.5,-0.5,0,0.5,1.5] + + num = core.ufloat_from_sample(test_sample) + + assert numbers_close(num.n,0) + assert numbers_close(num.s,0.5) + def test_array_comparisons(): "Test of array and matrix comparisons" From 4e161a9e3304890961e3f51750cecc3f005b0932 Mon Sep 17 00:00:00 2001 From: andrewgsavage Date: Fri, 20 Dec 2024 00:49:02 +0000 Subject: [PATCH 05/21] Update numpy_guide.rst --- doc/numpy_guide.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/numpy_guide.rst b/doc/numpy_guide.rst index 110e7152..998f8298 100644 --- a/doc/numpy_guide.rst +++ b/doc/numpy_guide.rst @@ -149,7 +149,7 @@ Numbers with uncertainties from samples Numbers with uncertainties can be found from samples of numbers without uncertainties using :func:`ufloat_from_sample`. This is an estimate on the true value of the number and its uncertainty, -and so it works best for large samples that are normally dristobuted. +and so it works best for large samples that are normally distributed. .. index:: pair: testing and operations (in arrays); NaN From 82842e9526df7595ff8a93bc36c08bc8de861648 Mon Sep 17 00:00:00 2001 From: andrewgsavage Date: Fri, 20 Dec 2024 00:50:18 +0000 Subject: [PATCH 06/21] Update core.py --- uncertainties/unumpy/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uncertainties/unumpy/core.py b/uncertainties/unumpy/core.py index e2eb47cb..88f4c69f 100644 --- a/uncertainties/unumpy/core.py +++ b/uncertainties/unumpy/core.py @@ -123,7 +123,7 @@ def ufloat_from_sample(sample): """ Return a ufloat where the nominal value and standard deviation are the mean and uncertainty on the mean of the sample of values. - If a the sample is a set of random measurements of a normal distribtuion + If a the sample is a set of random measurements of a normal distribution then the returned value will contain the best estimate of the mean and standard deviation of the distribution. """ From 98bb34afcd215ff069a6ce04884fbd968ba389eb Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Sat, 21 Dec 2024 17:07:40 +0000 Subject: [PATCH 07/21] Revert "Update core.py" This reverts commit 82842e9526df7595ff8a93bc36c08bc8de861648. --- uncertainties/unumpy/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uncertainties/unumpy/core.py b/uncertainties/unumpy/core.py index 88f4c69f..e2eb47cb 100644 --- a/uncertainties/unumpy/core.py +++ b/uncertainties/unumpy/core.py @@ -123,7 +123,7 @@ def ufloat_from_sample(sample): """ Return a ufloat where the nominal value and standard deviation are the mean and uncertainty on the mean of the sample of values. - If a the sample is a set of random measurements of a normal distribution + If a the sample is a set of random measurements of a normal distribtuion then the returned value will contain the best estimate of the mean and standard deviation of the distribution. """ From 6274859397f4a342115134f764aca1f72d349411 Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Sat, 21 Dec 2024 17:07:47 +0000 Subject: [PATCH 08/21] Revert "Update core.py" This reverts commit 314c32da2033437e1b57db78d3c5f87379dd327f. --- uncertainties/unumpy/core.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/uncertainties/unumpy/core.py b/uncertainties/unumpy/core.py index e2eb47cb..763f57d9 100644 --- a/uncertainties/unumpy/core.py +++ b/uncertainties/unumpy/core.py @@ -119,16 +119,6 @@ class from this module) are passed through untouched (because a ############################################################################### -def ufloat_from_sample(sample): - """ - Return a ufloat where the nominal value and standard deviation are - the mean and uncertainty on the mean of the sample of values. - If a the sample is a set of random measurements of a normal distribtuion - then the returned value will contain the best estimate of the mean - and standard deviation of the distribution. - """ - return uncert_core.ufloat(numpy.mean(sample),numpy.std(sample,ddof=1)/numpy.sqrt(len(sample))) - def derivative(u, var): """ From ebe0591e2fd78dee50b90d22e88020087ef5dec7 Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Sat, 21 Dec 2024 20:43:12 +0000 Subject: [PATCH 09/21] Update core.py --- uncertainties/core.py | 51 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/uncertainties/core.py b/uncertainties/core.py index c521a87f..4ec0f14e 100644 --- a/uncertainties/core.py +++ b/uncertainties/core.py @@ -17,6 +17,9 @@ from builtins import str, zip, range, object from math import sqrt, isfinite # Optimization: no attribute look-up +from statistics import mean as stats_mean +from statistics import stdev as stats_stddev + import copy import collections @@ -1004,6 +1007,54 @@ def ufloat_fromstr(representation, tag=None): (nom, std) = str_to_number_with_uncert(representation.strip()) return ufloat(nom, std, tag) +def ufloat_from_sample(sample, method="gaussian", axis=None): + ''' + Converts a collection of values into a ufloat. + + Arguments: + ---------- + sample: list or numpy array of numbers + The sample of values + + method: optional string + The method used to calculate the ufloat. currently only + the 'gaussian' method is implimented. + + gaussian: The nominal value is the mean of the sample. + The standard deviantion is the error on the mean. This + method assumes that the sample follows a gaussian + distrobution, and works best for large samples. This + method works well to find an estimate of a fixed value + that has been measured multiuple times with some random + error. + + axis: integer or None + Only when the sample is a numpy array. The axis along + which the ufloats are computed. + + ''' + + if method=="gaussian": + + if numpy is None: + #if numpy is not present, use pythons statistics functions instead + mean_value=stats_mean(sample) + error_on_mean=stats_stddev(sample)/sqrt(len(sample)-1) + + else: + #if numpy is present, use the faster numpy functions that can handle a wider range of inputs + mean_value=numpy.mean(sample, axis=axis) + error_on_mean=numpy.std(sample, ddof=1, axis=axis)/numpy.sqrt(len(sample)) + + return ufloat(mean_value,error_on_mean) + + else: + msg={ + "method must be one of the implemented methods" + } + raise ValueError(msg) + + def ufloat(nominal_value, std_dev=None, tag=None): """ From 58a1220edde5ca451e27aa5aa037db3c01f7fffd Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Sat, 21 Dec 2024 20:43:57 +0000 Subject: [PATCH 10/21] Revert "Update test_unumpy.py" This reverts commit 86f8f7d3b33549a17e953a97ca53808db72c03a0. --- tests/test_unumpy.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/test_unumpy.py b/tests/test_unumpy.py index 4974caae..783fd336 100644 --- a/tests/test_unumpy.py +++ b/tests/test_unumpy.py @@ -290,16 +290,6 @@ def test_component_extraction(): assert numpy.all(unumpy.std_devs(mat) == [0.1, 0.2]) assert type(unumpy.nominal_values(mat)) == numpy.matrix -def test_ufloat_from_sample(): - "Test genarating a number with an uncertainty from a sample" - - test_sample=[-1.5,-0.5,0,0.5,1.5] - - num = core.ufloat_from_sample(test_sample) - - assert numbers_close(num.n,0) - assert numbers_close(num.s,0.5) - def test_array_comparisons(): "Test of array and matrix comparisons" From e864bd0cf2821f0132e12cc413c2384f9e269a80 Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Sat, 21 Dec 2024 21:21:48 +0000 Subject: [PATCH 11/21] Update core.py --- uncertainties/core.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/uncertainties/core.py b/uncertainties/core.py index 4ec0f14e..360aca8e 100644 --- a/uncertainties/core.py +++ b/uncertainties/core.py @@ -74,6 +74,9 @@ except ImportError: numpy = None +if numpy != None: + from uncertainties.unumpy.core import uarray + def correlated_values(nom_values, covariance_mat, tags=None): """ @@ -1030,7 +1033,8 @@ def ufloat_from_sample(sample, method="gaussian", axis=None): axis: integer or None Only when the sample is a numpy array. The axis along - which the ufloats are computed. + which the ufloats are computed. If None (the default value) + sample is the whole flattend array. ''' @@ -1041,13 +1045,28 @@ def ufloat_from_sample(sample, method="gaussian", axis=None): mean_value=stats_mean(sample) error_on_mean=stats_stddev(sample)/sqrt(len(sample)-1) + return ufloat(mean_value,error_on_mean) + else: #if numpy is present, use the faster numpy functions that can handle a wider range of inputs mean_value=numpy.mean(sample, axis=axis) - error_on_mean=numpy.std(sample, ddof=1, axis=axis)/numpy.sqrt(len(sample)) + + #the size of each sample being collected + sample_size=0 + + if axis == None: + sample_size=numpy.size(sample) + else: + sample_size=numpy.shape(sample)[axis] - return ufloat(mean_value,error_on_mean) + error_on_mean=numpy.std(sample, ddof=1, axis=axis)/numpy.sqrt(sample_size) + if len(numpy.shape(mean_value))==0: + # if the output is a single ufloat + return ufloat(mean_value,error_on_mean) + else: + #if the output is an array of ufloats + return uarray(mean_value,error_on_mean) else: msg={ "method must be one of the implemented methods" From aa4852a684f10fe343c587768d7009943dd7e313 Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Sat, 21 Dec 2024 22:11:44 +0000 Subject: [PATCH 12/21] Update core.py --- uncertainties/core.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/uncertainties/core.py b/uncertainties/core.py index 360aca8e..b9a802f6 100644 --- a/uncertainties/core.py +++ b/uncertainties/core.py @@ -74,10 +74,6 @@ except ImportError: numpy = None -if numpy != None: - from uncertainties.unumpy.core import uarray - - def correlated_values(nom_values, covariance_mat, tags=None): """ Return numbers with uncertainties (AffineScalarFunc objects) @@ -1065,8 +1061,14 @@ def ufloat_from_sample(sample, method="gaussian", axis=None): # if the output is a single ufloat return ufloat(mean_value,error_on_mean) else: - #if the output is an array of ufloats - return uarray(mean_value,error_on_mean) + #if the output is an array of ufloats (duplicate of code from unnumpy.core.uarray to avoid circular import) + return numpy.vectorize( + # ! Looking up uncert_core.Variable beforehand through + # '_Variable = uncert_core.Variable' does not result in a + # significant speed up: + lambda v, s: Variable(v, s), + otypes=[object], + )(mean_value, error_on_mean) else: msg={ "method must be one of the implemented methods" From 779459bf84bee1fdbcc57df1f8a2eca8355d8bcc Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Sat, 21 Dec 2024 23:31:50 +0000 Subject: [PATCH 13/21] Update core.py --- uncertainties/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uncertainties/core.py b/uncertainties/core.py index b9a802f6..81e60088 100644 --- a/uncertainties/core.py +++ b/uncertainties/core.py @@ -1071,7 +1071,7 @@ def ufloat_from_sample(sample, method="gaussian", axis=None): )(mean_value, error_on_mean) else: msg={ - "method must be one of the implemented methods" + "{} is not one of the implemented methods".format(method) } raise ValueError(msg) From 30a52f15cc7c74f3dee015d7909e7987fa161016 Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Sat, 21 Dec 2024 23:31:54 +0000 Subject: [PATCH 14/21] Update test_uncertainties.py --- tests/test_uncertainties.py | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/tests/test_uncertainties.py b/tests/test_uncertainties.py index 0cb81807..437c1433 100644 --- a/tests/test_uncertainties.py +++ b/tests/test_uncertainties.py @@ -27,6 +27,8 @@ except ImportError: np = None +if np != None: + from uncertainties.unumpy.core import nominal_values,std_devs def test_value_construction(): """ @@ -146,6 +148,71 @@ def test_ufloat_fromstr(): assert numbers_close(num.std_dev, values[1]) assert num.tag == "test variable" +def test_ufloat_from_sample(): + "Test genarating a number with an uncertainty from a sample" + + #the test imputs for the sample paramiter + test_samples=[ + [-1.5,-0.5,0,0.5,1.5] #test standard list input + ] + + #the test imputs for the other arguments + optional_args=[{}] + + #the expected nominal values + expected_n=[0] + + #expected standard deviations + expected_s=[0.5] + + if np != None: + #include extra tests for numpy arrays + test_samples+=[ + np.array([-1.5,-0.5,0,0.5,1.5]), + np.array([ + [-3, -1, 0, 1, 3], + [-1.5, -0.5, 0, 0.5, 1.5], + [-0.75, -0.25, 0, 0.25, 0.75], + [0, 0, 0, 0, 0], + [1.5, 0.5, 0, -0.5, -1.5] + ]), + np.array([ + [-3, -1, 0, 1, 3], + [-1.5, -0.5, 0, 0.5, 1.5], + [-0.75, -0.25, 0, 0.25, 0.75], + [0, 0, 0, 0, 0], + [1.5, 0.5, 0, -0.5, -1.5] + ]) + ] + optional_args+=[ + {}, + {'axis':0}, + {'axis':1} + ] + expected_n+=[ + 0, + [-0.75,-0.25,0.0,0.25,0.75], + [0, 0, 0, 0, 0] + ] + expected_s+=[ + 0.5, + [0.75,0.25,0.0,0.25,0.75], + [1, 0.5, 0.25, 0, 0.5] + + ] + + + #run the tests + for i,sample in enumerate(test_samples): + + num=uncert_core.ufloat_from_sample(sample,**(optional_args[i])) + + #check nominal values + assert(np.allclose(nominal_values(num),expected_n[i])) + + #check standard deviations + assert(np.allclose(std_devs(num),expected_s[i])) + ############################################################################### From dac42d158401611c1d6e557d783351d6bea80410 Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Sat, 21 Dec 2024 23:32:31 +0000 Subject: [PATCH 15/21] Revert "Update numpy_guide.rst" This reverts commit 4e161a9e3304890961e3f51750cecc3f005b0932. --- doc/numpy_guide.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/numpy_guide.rst b/doc/numpy_guide.rst index 998f8298..110e7152 100644 --- a/doc/numpy_guide.rst +++ b/doc/numpy_guide.rst @@ -149,7 +149,7 @@ Numbers with uncertainties from samples Numbers with uncertainties can be found from samples of numbers without uncertainties using :func:`ufloat_from_sample`. This is an estimate on the true value of the number and its uncertainty, -and so it works best for large samples that are normally distributed. +and so it works best for large samples that are normally dristobuted. .. index:: pair: testing and operations (in arrays); NaN From bf49d940ea91ecc7eb4b3b09f716f032c1a349a3 Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Sat, 21 Dec 2024 23:32:46 +0000 Subject: [PATCH 16/21] Revert "Update numpy_guide.rst" This reverts commit 4fba1749ab8b5cdca105554ab34804246101e27e. --- doc/numpy_guide.rst | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/doc/numpy_guide.rst b/doc/numpy_guide.rst index 110e7152..f350765f 100644 --- a/doc/numpy_guide.rst +++ b/doc/numpy_guide.rst @@ -141,16 +141,6 @@ and is not named :func:`acos` like in the :mod:`math` module). The definition of the mathematical quantities calculated by these functions is available in the documentation for :mod:`uncertainties.umath`. -.. index:: Numbers with uncertainties from samples - -Numbers with uncertainties from samples ---------------------------------------- - -Numbers with uncertainties can be found from samples of numbers -without uncertainties using :func:`ufloat_from_sample`. This is -an estimate on the true value of the number and its uncertainty, -and so it works best for large samples that are normally dristobuted. - .. index:: pair: testing and operations (in arrays); NaN From 205b913637c80f2234ace6f435c7e7da9cc7ab02 Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Sat, 21 Dec 2024 23:34:02 +0000 Subject: [PATCH 17/21] Update CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 237c0432..ae9463c3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,7 +12,7 @@ Changes time. Now such a function can be imported but if the user attempts to execute it, a `NotImplementedError` is raised indicating that the function can't be used because `numpy` couldn't be imported. -- Added unumpy.ufloat_from_sample to create a ufloat from a random sample of a variable. +- Added `uncertainties.ufloat_from_sample()` to create a ufloat from a random sample of a variable. Fixes: From 2951fcf8759af273626e758cc6e92cda9f2d45ff Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Sat, 21 Dec 2024 23:39:23 +0000 Subject: [PATCH 18/21] Update user_guide.rst --- doc/user_guide.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/user_guide.rst b/doc/user_guide.rst index 5ba5d465..851ef1af 100644 --- a/doc/user_guide.rst +++ b/doc/user_guide.rst @@ -534,6 +534,12 @@ manner**. This is what the :func:`nominal_value` and >>> uncertainties.std_dev(3) 0.0 +Numbers with uncertainties can be found from samples of numbers +without uncertainties using :func:`ufloat_from_sample`. This is +an estimate on the true value of the number and its uncertainty. +The current implimented method returns the mean and the error on the +mean, so it works best for large samples that are normally dristobuted. + Finally, a utility method is provided that directly yields the `standard score `_ (number of standard deviations) between a number and a result with From e9ff10838a122fb80b3c996cdc0d1c8ed6dc3511 Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Sat, 21 Dec 2024 23:45:27 +0000 Subject: [PATCH 19/21] Update user_guide.rst --- doc/user_guide.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/user_guide.rst b/doc/user_guide.rst index 851ef1af..8e084090 100644 --- a/doc/user_guide.rst +++ b/doc/user_guide.rst @@ -536,9 +536,9 @@ manner**. This is what the :func:`nominal_value` and Numbers with uncertainties can be found from samples of numbers without uncertainties using :func:`ufloat_from_sample`. This is -an estimate on the true value of the number and its uncertainty. -The current implimented method returns the mean and the error on the -mean, so it works best for large samples that are normally dristobuted. +an estimate of the true value of the number and its uncertainty. +The currently implemented "gaussian" method returns the mean and the error on the +mean, so it works best for large samples that are normally distributed. Finally, a utility method is provided that directly yields the `standard score `_ From 3c250d40d743e5182935e039e145e0eb2fdfecab Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Sat, 21 Dec 2024 23:48:37 +0000 Subject: [PATCH 20/21] Update core.py --- uncertainties/core.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/uncertainties/core.py b/uncertainties/core.py index 81e60088..ca966cdc 100644 --- a/uncertainties/core.py +++ b/uncertainties/core.py @@ -1016,13 +1016,13 @@ def ufloat_from_sample(sample, method="gaussian", axis=None): The sample of values method: optional string - The method used to calculate the ufloat. currently only - the 'gaussian' method is implimented. + The method used to calculate the ufloat. currently, only + the 'gaussian' method is implemented. gaussian: The nominal value is the mean of the sample. - The standard deviantion is the error on the mean. This + The standard deviation is the error on the mean. This method assumes that the sample follows a gaussian - distrobution, and works best for large samples. This + distribution, and works best for large samples. This method works well to find an estimate of a fixed value that has been measured multiuple times with some random error. @@ -1030,7 +1030,7 @@ def ufloat_from_sample(sample, method="gaussian", axis=None): axis: integer or None Only when the sample is a numpy array. The axis along which the ufloats are computed. If None (the default value) - sample is the whole flattend array. + the sample is the whole flattened array. ''' From 2d592d60ec6c57b7ab01d37783315e000ad3cb33 Mon Sep 17 00:00:00 2001 From: Myles244 <43722484+Myles244@users.noreply.github.com> Date: Sun, 22 Dec 2024 00:14:29 +0000 Subject: [PATCH 21/21] Update core.py --- uncertainties/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uncertainties/core.py b/uncertainties/core.py index ca966cdc..66381f64 100644 --- a/uncertainties/core.py +++ b/uncertainties/core.py @@ -18,7 +18,7 @@ from math import sqrt, isfinite # Optimization: no attribute look-up from statistics import mean as stats_mean -from statistics import stdev as stats_stddev +from statistics import stdev as stats_stdev import copy import collections @@ -1039,7 +1039,7 @@ def ufloat_from_sample(sample, method="gaussian", axis=None): if numpy is None: #if numpy is not present, use pythons statistics functions instead mean_value=stats_mean(sample) - error_on_mean=stats_stddev(sample)/sqrt(len(sample)-1) + error_on_mean=stats_stdev(sample)/sqrt(len(sample)-1) return ufloat(mean_value,error_on_mean)