You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the std() or variance() functions on an array of values with units assigned results in an error. This seems to be in contrast to every other function in the Statistics category (mean(), median(), mad(), etc), which seem to operate happily on arrays of unit'ed values.
I'm not sure if this is a bug or a feature request, but I'd like to request that support for unit'ed values be added to the std() and variance() functions.
Example of error
vals=[2mm,5mm,6mm]math.mean(vals)// 4.3333333333333 mmmath.std(vals)// TypeError: Cannot calculate std, unexpected type of argument (type: Unit, value: {"mathjs":"Unit","value":2,"unit":"in","fixPrefix":false})
I note, however, that I can write a simple function with map() that calculates the standard deviation of this array without difficulty:
math.sqrt(math.sum(math.map(vals,f(x)=(x-mean(vals))^2))/math.size(vals)[1])// 1.6996731711976 mm
Or in the expression parser on the homepage:
The text was updated successfully, but these errors were encountered:
Using the
std()
orvariance()
functions on an array of values with units assigned results in an error. This seems to be in contrast to every other function in the Statistics category (mean()
,median()
,mad()
, etc), which seem to operate happily on arrays of unit'ed values.I'm not sure if this is a bug or a feature request, but I'd like to request that support for unit'ed values be added to the
std()
andvariance()
functions.Example of error
I note, however, that I can write a simple function with
map()
that calculates the standard deviation of this array without difficulty:Or in the expression parser on the homepage:
The text was updated successfully, but these errors were encountered: