Live data from Hacker News

A word for a value between 0 and 1 (inclusive)

english.stackexchange.com

201–210 of 325 posts

Re: A word for a value between 0 and 1 (inclusive)

#201
post #90

I don't think this is a naming issue at all. In the provided example, 'Accuracy' is the correct name for the parameter, as that's what the parameter represents, accuracy. The fact that accuracy should be given as a value in an interval from 0 to 1 should be a property of parameter type . In other words, the parameter should not be a float, but a more constrained type that allows floats only in [0,1]. EDIT: Some of yo…

I think this is the best answer. This got me thinking: What about a situation where the accuracy is given in a real-life unit. For example, the accuracy of a GPS measurement, given in meters. I've sometimes used names like 'accuracyInMeters' to represent this, but it felt a bit cumbersome. Edit: Thinking more about it, I guess you could typealias Float to Meters, or something like that, but also feels weird to me.

I usually do the "inMeters" thing.

Another thing you can do is define a "METER" constant equal to 1. You can then call your function like this: func(1.5 * METER), and when you need a number of meters, you can do "accuracy / METER". The multiplication and division should be optimized away.

Good thing about that is that you can specify the units you want, for example you can set FOOT to 0.3048 and do "5. * FOOT" and get back your result in centimeters by doing "accuracy / CENTIMETER". The last conversion is not free if the internal representation is in meter but at least, you can do it and it is readable.

If you are going to use such distances a lot, at least in C++, you can get a bit of help from the type system. Define a "distance" class operator overloads, constants and convenience functions to enforce consistent units. Again, the optimizer should make it not more costly than using raw floats if that's what you decide to use as an internal representation.

Re: A word for a value between 0 and 1 (inclusive)

#202
post #197

Ratio? Probability? Proportion? Out of the answers there I like AccuracyNormalized best. That immediately conveys (to me at least) what it is and what its magnitude will be bounded by. Or...if you were writing Java or Swift NonNegativeMagnitudelessFractionalQuantity

I always use ratio for this kind of number. Though it could be bigger than 1 since 120% == 1.2

Yes, I was thinking something like proper ratio but I don't think that's standard plus I think it's getting pedantic.

The takeaway is words are mostly a leaky abstraction, imperfect model for math concepts.

But I guess if you're a clever programmer you could call it a ThielAccuracy, or ThielRatio

Re: A word for a value between 0 and 1 (inclusive)

#203
post #82

Earlier quoted context omitted.

Depends how you look at it, I guess. 0 to 100% translates to 0 to 1. edit: but I guess it is wrong, because % is ambiguous - it can mean fraction, it can mean growth

That's like saying that inches are the same thing as yards because you can convert from one to the other.

What I was taught in school is that "percent" doesn't refer to 0 - 100, it refers to 0% - 100% which is equal to 0 - 1 (not really a conversion, actually equal).

As 0% and 100% aren't floats (they're more like formatted values), seeing AccuracyPercent in the question had me thinking there was nothing more accurate.

Re: A word for a value between 0 and 1 (inclusive)

#205
post #104
post #90

I don't think this is a naming issue at all. In the provided example, 'Accuracy' is the correct name for the parameter, as that's what the parameter represents, accuracy. The fact that accuracy should be given as a value in an interval from 0 to 1 should be a property of parameter type . In other words, the parameter should not be a float, but a more constrained type that allows floats only in [0,1]. EDIT: Some of yo…

But what do you name the variable in the languages that don't support such a constrained type feature (the majority of them)?

Object-oriented languages have equivalent constructs, so I would say that this is doable in the vast majority of languages in common use:

https://news.ycombinator.com/item?id=24374372

http://wiki.c2.com/?ValueObject

Re: A word for a value between 0 and 1 (inclusive)

#207
I've called this 'unit real' in the past, but wasn't happy with it. 'Portion' is good, from one of the answers. ('Proportion' and 'fraction' unfortunately both suggest a ratio of integers instead of a unit real. It'd sure be convenient if these two different words weren't fixed to that same meaning.)

For neologisms, 'tweening' comes to mind. (Think of the coefficient of a convex combination. 'Tweenness' feels just a little too long.) 'Fractile' from the stackexchange thread would also work.

Booleans have the same problem that we lack a plain English short word for "yes or no answer". I think we ought to start pushing 'bool' or 'boole' out of our jargon and into common English.

Re: A word for a value between 0 and 1 (inclusive)

#208

I've called this 'unit real' in the past, but wasn't happy with it. 'Portion' is good, from one of the answers. ('Proportion' and 'fraction' unfortunately both suggest a ratio of integers instead of a unit real. It'd sure be convenient if these two different words weren't fixed to that same meaning.) For neologisms, 'tweening' comes to mind. (Think of the coefficient of a convex combination. 'Tweenness' feels just a…

> Booleans have the same problem that we lack a plain English short word for "yes or no answer".

"Binary" is the term I use. E.g., "It's not a binary proposition" to call out a false dichotomy.

Re: A word for a value between 0 and 1 (inclusive)

#209

Earlier quoted context omitted.

I think generally normalized quantities maintain their original units whereas in your ratio case the unit is dropped. Units in the abstract sense I guess, such as this is a measurement along this vector or this is a ratio of any vector.

I think it's the opposite way round: normalisation results in units being dropped. The typical, most common, definition of normalisation is value ÷ max possible value, giving a result in [0,1]. (More general definitions of normalisation exist e.g. if you rescale so the standard deviation is a fixed value, or even use non linear rescaling, that could count, but never mind all that.) The parent comment's example of "po…

Hmm when I think of 'normalizing' I don't think of dividing by a max at all - in my experience it is more taking a quantity (perhaps in English measurement) and transferring to a more 'standard' unit (say metric).

In general I don't think normalization always includes a sense of being in a bounded interval. From a mathematical perspective you could perhaps say normalization is achieved by multiplying your quantity by a 1D operator. You can't change the dimensionality this way, but are certainly changing 'units' a la mm in the x direction -> m in the x direction for example. I guess what I'm saying is that 'normalized' and the like are not the best fit for the SO question.

If I could take my own shot at the SO challenge from a mathematical perspective it would perhaps be sigmoid. Where the result of a normalization function takes a 1D value and maps it to a similar 1D value, the sigmoid takes a 1D value and maps it to a similar 1D value between (0, 1). So if I want to drop the previous information and only keep the resulting map, I can say 'this is my sigmoided value' - IE it is impossible for it to be outside of that range. Unfortunately sigmoid also connotates a differentiable curve which is extraneous information...

https://en.wikipedia.org/wiki/Normalization_(statistics)

https://en.wikipedia.org/wiki/Sigmoid_function

Re: A word for a value between 0 and 1 (inclusive)

#210

Earlier quoted context omitted.

Unfortunately, creating a constrained type like this isn't easy (or even doable) in all programming languages. Fortunately, my preferred programming language, Raku, makes creating this sort of subset trivially easy[0]: subset UnitInterval of Real where 0 ≤ * ≤ 1 [0]: https://docs.raku.org/language/typesystem#index-entry-subset...

Is there a difference between ≤ and <= in Raku? Curious why you used ≤ in your example.

They're equivalent, Raku defines both Ascii compatible and Unicode names for typical operators. I expect they used ≤ because it looks nicer.
Post reply on HN