324 comments

[ 4.3 ms ] story [ 156 ms ] thread
“mantissa” (https://en.wikipedia.org/wiki/Common_logarithm#Mantissa_and_...) comes close, but excludes 1.

IEEE 754 sort-of has that as a part of a float, too (https://en.wikipedia.org/wiki/Significand), and people use the term “mantissa” for it, but it has to special-case 0.

⇒ barring better suggestions, I think I would stretch the definition of mantissa a bit further.

So the word mantissa has two different meanings that show up in really similar contexts. In

  log(120) = log(1.2 × 10²) = 2.079,
you could call both the .079 and the 1.2 a mantissa. The first is in the range [0,1) and the second, aka significand, is in [1,10) for base 10.

And really one mantissa is just the log of the other.

Can we just represent 1 here as 0.999...?
There are many ways to represent 1, but it’s still 1.
(comment deleted)
It’s 1, but is it a mantissa?

The linked Wikipedia article just says that the mantissa is “the fractional part.”

The fractional part of x is what you have left after you subtract the largest integer k ≤ x.

Hence the fractional part is always less than 1. Since 0.999... = 1, it is not less than 1, so cannot be the fractional part of any number.

Makes sense, thanks.
There is an answer by someone who suggested a neologism, check the link for source.
Thing is, whilst a mantissa is indeed between 0 and 1, not every number between 0 and 1 is a mantissa. Specifically, a mantissa suggests the existence of a significant.
I'd agree with "portion" or "part" -- describes a percentage in decimal notation, to me at least.
What about "fraction"? That's what I tend to use in my own code, although it could be greater than 1 potentially.
That's a feature, in case you need to crank the power up to 11.
(comment deleted)
How about just oTo1InclusiveVal ? I know very simple, but would get the job done ?
> substituting o for a '0'

pls no

sorry must have typed by mistake in mobile
we can put underscore before the 0 so that it is a valid name
Given that no existing word is quite right for this common problem, a neologism is best. And "primantissa" delights: I will smile every time I use it.
(comment deleted)
Naming the variable "accuracyPrimantissa" doesn't seem delightful to me, though.
I would actually call this a bit of an antipattern.

`accuracy` seems fine to me -- although a more descriptive function name than `FuncName` might suggest a better parameter name as well.

Digging through the dictionary to find the perfect word means that whoever reads this code is likely going to have to do the same -- why would you ask them to do that?

If you aren't referring to a common mathematical or physical concept, and the word you need it isn't a part of your domain language, you're better off with "accurate but slightly vague" over "almost precise" or "precise but obscure".

It seems like the author's need would be better met by readable tests, guard conditions, and -- if this is part of an API -- documentation that describes how `accuracy` is used.

You're not wrong but it would be nice to have a word for this incredibly common type of value still.
As a mathematician, I heartily agree.
I couldn't agree more.

If you can't express it using the features of the language itself (custom domain-specific type, compile contracts?), limit yourself to putting this info into the docs, but keep naming simple.

Don't come up with fancy names. One of the commenters already declared (jokingly??) they'd "call it PropUnity, for proportion of unity, unity being 1".

Holy smokes Batman. As a code maintainer, I imagine encountering "accuracy" (even though it isn't fully accurately named itself) would confuse me somewhat less than "propUnity".

(comment deleted)
Wouldn’t this be a normalized / unitized float?

Or at very least an absolute normalized float

I'd personally go with "percent", but because there's so many correct options, it shouldn't matter as long as it's consistent in the code base. Otherwise it just becomes bike-shedding bait.
Right but it’s specifically not, and liable to make people think “3” is an acceptable input
Again, this is bike shedding bait. I'm going by my own experience with basic mathematics in my American education where "percent" is something you multiply a number by, and usually ranges from 0 to 1.

Ex. 50% of 12 marbles is 6 (*.5, 50%).

But just looking at all the different answers in the comments here means there's no consensus on a "right" way. Hence bike shedding. A decent code base should be consistent so it can focus on more important things.

fwiw, this post was inspired by a twitter thread i created yesterday (https://twitter.com/v21/status/1301451641699340288), where i collected examples of people getting annoyed that this term doesn't exist... and most of those were inspired by frustration at this being called a percentage when it wasn't. so if you want a nice collection of people stubbing their toe on the word percentage, it's out there.
There might be bike shedding for the best answer, but this is just incorrect. Percent literally means "for one hundred"
(comment deleted)
> "percent" ... usually ranges from 0 to 1

That’s not a percentage. A percentage is between 0 and 100.

Technically even that's incorrect - percentages can be negative and greater than 100 as well.

A doubling expressed as a percentage of a given baseline would be 200%; economic growth during a recession is typically expressed by a negative percentage.

‘Per’ means ‘divided by’, ‘cent’ means 100. Units implicitly multiply, and x/100 == x*0.01.

Percent is a fancy way to 0.01, just as ‘dozen’ is a fancy way to say 12.

Percent has some strong norms around its usage (no-one buys 1200% eggs at the supermarket) but you can’t ignore the mathematical meaning.

In both cases, if someone used them as a type name, conversion to floats should involve multiplying by the unit.

The real answer to this XY is comments and documentation, imo. If you want to make it obvious without reading docs or code, get an IDE with doxygen-aware completion.

Edit: also, put it into typename, not into argname.

From a practical point of view, a new/academic word would still require serp lookup in most cases. If it were in a type, like float01, one could easily jump to the function definition and then to the type definition, described by a comment. In the case of argument naming, there is no place to jump to, only googling remains.
"float zero_to_one" is pretty short and obvious. The caller can maybe even guess by the context of the function name that it probably accepts 0 and 1.
I typically use "_fraction" to indicate this in floating point variable names, along with a comment explicitly mentioning the range from 0 to 1 somewhere. Seems to minimize confusion pretty well.
I’ve also seen “fraction” used for this concept in Apple/NeXT APIs. E.g., “-[NSImage drawInRect:fromRect:operation:fraction:]” and “-[UIViewPropertyAnimator fractionComplete]”.
Better languages will let you call the variable just "accuracy", but with type "float 0 to 1 inclusive" with some literal syntax; so from

    function FuncName(float AccuracySOMETHING)
to

    function FuncName([0...1] accuracy)
Which languages allow this? It looks suspiciously like dependent typing to me
FWIW, that's not dependent typing, because the type doesn't depend on run-time values. A bool is either true or false, a [0...1] is either 0 or, ..., or 1.

As for which languages allow it. I'm not sure for floats, but Pascal let you do it for ints for sure. https://wiki.freepascal.org/subrange_types

I'd call it PropUnity, for proportion of unity, unity being 1.
"Normalized".

That's what we call data that have been scaled to fit on a tidy axis.

This has a nice confusion factor because IEEE calls such floats denormalized. Because they may have extra precision and different format.
Normalized could also imply demeaned.
You could also call that centred to clear up confusion, or mean-subtracted to be more specific. I think if you're specifically dealing with statistical quantities it should be obvious, e.g. standardised if you also scale to unit variance.

Personally if I saw normalised I would assume scaled by a constant, not offset (as in subtraction).

One problem with the word normalised is that it implies that there is some true original value from before normalisation that isn't necessarily between 0 and 1. Of course if that's true then the word is ideal, but if not then it's confusing.
Genuine question, i'm no math expert: if you're using the value by multiplying it with some other value, does that not imply it qualifies as normalised?

i.e. say you have a width of 500 and you want to move half way across so you have this value of 0.5 to get 250. By dividing 250 by 500, aren't we in fact normalising it?

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 "position along width ÷ total width" certainly fits that bill.

Whenever you divide something by the max of that something, the max is going to have the same units as the original value and you're bound to end up cancelling them. Or put another way, if you rescale 10cm into 0.5, it's certainly not 0.5cm so the units are either dropped or, at least, changed e.g. you could argue you've got 0.5x where x is the unit equal to 20cm.

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

Of course the literal meaning of "normalisation" is to make more "normal", and that can mean almost anything at all. Even the Wikipedia article you linked to starts with "normalization can have a range of meanings". If you have heard that word most used with one meaning and I have heard it most used with another meaning then that doesn't invalidate either of those definitions.

The Wikipedia article you linked to gives two very broad definitions in the lead. The definition covered in the first paragraph is "adjusting values measured on different scales to a notionally common scale", which seems to be what you're talking about.

The definition covered in the second paragraph is "the creation of shifted and scaled versions of statistics", in particular "some types of normalization involve only a rescaling, to arrive at values relative to some size variable". I'm not comfortable with the use of "of statistics" in that second definition: the very first example is in the article standard score [1], which is about a rescaled element of the population, not a rescaled statistic. In any case, outside of statistics, a rescaling is a common meaning for this word, and a rescaled statistic is clearly just a special case of this. I think it was clear from the context that we were talking about this meaning originally. By far the most common case of this is a linear rescaling (including translation) to [0,1] but I was already up front that this is just a special case.

As for your sigmoid comment, I may have misunderstood but it sounds like you're saying that if you have a variable in the range in [0,1] then it can be described as the result of a sigmoid function. My objection to this is the same as my original objection to calling such as variable "normalised": it is a confusing variable name to use unless you actually did get it by applying a sigmoid function to something, not just because it holds a value that could hypothetically be obtained from a sigmoid function (but you didn't).

[1] https://en.wikipedia.org/wiki/Standard_score

(comment deleted)
> if you're using the value by multiplying it with some other value, does that not imply it qualifies as normalised

Certainly, "normalisation" can mean something more general than "rescale to the interval [0,1]".

For example, "rescaling to the interval [0, 20]" might make sense in some contexts and would usually count as a type of normalisation, and would still involve muliplying by a number. But that would be multiplying by (20 / max possible value) rather than the typical case of multiplying by (1 / max possible value).

So normalisation can mean something more general than the most usual common case, but it's not just any old "multiplying it with some other value". It has to specifically for the purpose of rescaling to some fixed, more useful/sensible range.

> say you have a width of 500 and you want to move half way across so you have this value of 0.5 to get 250

This is a great example of multiplication that isn't normalisation! You've multiplied by 0.5 to get the midpoint, but that process isn't normalisation because you've not ended up with some more sensible range. You started with [0,infinity) (the set of all possible widths) and ended up with that same infinite range.

> By dividing 250 by 500

Hang on, I'm confused about your example: are you asking about 500*0.5 (=250) or 250/500 (=0.5)? If it's the latter than that's normalisation, and not even something fancy or general but classic linear rescaling to the interval [0,1]. Yes, that's certainly normalisation.

----

Going back to my original comment: I was talking about values that were in the range 0 to 1 that hadn't reached that range by being multiplied by anything at all; they were just naturally in that range to begin with. For example, a probability would fit this bill.

> If it's the latter than that's normalisation.

I'm very clumsily trying to say that if:

  width / maxWidth = normalWidth
then:

  normalWidth * maxWidth = width.
And so, even though we aren't necessary calculating the normal in the second equation, we can still name our variable a 'normal' as rearranging proves that is indeed what the value is.

Edit: formatting

That's what I use, too: "normalized floats." I would prefer a better word, though. I work a lot with audio, and "signed normalized floats" doesn't exactly roll off the tongue.
I am trying to think of what the opposite word is of normalization.
In the spaces I work in, people just say denormalized / denormalization.
That was easier than I imagined, thanks :)
Weirdization or maybe WeirdAlization if you like Weird Al.
"Normalized from 0 to 1" is what I say as a non-native english speaker
That isn't the right term. The standard meaning of "normalisation" in most scientific and engineering domains is shifting and scaling to get the sample mean to 0 and sample standard deviation to 1. I.e. it will almost always include both negative numbers and numbers larger than 1.
FWIW, I'd call that the z-score.
This would be like calling numbers constrained between 0 and 100 "multiplied". Yes, in some common situations you normalize data and it ends up between 0 and 1. And in some common situations you multiply and end up with numbers between 0 and 100 (like percentages).

But normalization doesn't always result in numbers between 0 and 1 and multiplication doesn't always result in numbers between 0 and 100.

Similarly, not all numbers constrained between 0 and 1 have been normalized and not all numbers constrained between 0 and 100 have been multiplied.

Add in the fact that the normalization statisticians most commonly use is z-score standardization (subtracting by the mean and dividing by standard deviation, resulting in data centered around 0), and you're going to end up with a lot of confusion. In fact, this example highlights that while normalization does mean "to scale" it doesn't mean that the result will always be bounded to a particular interval.

Probability
This is the right answer for anyone in data science
> between 0 and 1 (inclusive) [closed]

Why yes.

lol. really a ''closed'' interval.
If they had only asked about the interval without the endpoints, then we could still discuss the question.
I think I like portion. It is one of the only nouns that suggests an upper limit of 1. The other contender is 'unitized'. I don't like normalized because it feels too much like something that was actively normalized.
Why is everybody else suggesting things like 'accuracy', and 'between_0_1" when there exists an actual term: "unit interval" (the top answer)

https://en.wikipedia.org/wiki/Unit_interval#:~:text=In%20mat...

If you google accuracy, you'll get the noun. If you use a made up term, it'll probably return useless results.

Unit interval is the interval between 0 and 1. We need a word for a value within that interval.
Then "unitIntervalValue"
Right. That's the thing we need a word for :)

Unit Interval Value is nice but still a bit cumbersome. I mean if we all agreed right now it were called a "poog" then we could just say poog.

UnitInterval is the type. The name of the value should reflect its specific use.
Exactly. The best usage for this would be something like:

    typedef float UnitInterval;

    void do_something_accurately(UnitInterval accuracy);
This is the correct answer IMHO. (The variable name could also be "proportion" or "probability" depending on context, and the type name could more precisely be ClosedUnitInterval, but the idea of putting it in the type is IMHO correct.)

I don't know much about C (? I assume that's what this is), but in other languages you can even build a wrapper type and enforce invariants in construction if really necessary.

Of course, all that ceremony only makes sense if this is really a type you use multiple times. Otherwise I wouldn't bother.

ClosedUnitInterval surely describes the interval itself, not a member of that interval. The member would be ClosedUnitIntervalValue or something. This is the thing it would be nice to have a short name for.

Just as we say an integer is a member of the set called the integers.

We say our "X" (the word we are looking for) is a member of the set called the closed unit interval.

It's still not really "correct" IMO, I think it needs to be "UnitIntervalValue" as someone said above. I'd expect that things of type "UnitInterval" would be intervals, not values. "UnitInterval" would be like calling the type "Int32Range" instead of "Int32".

(NB: "In real life" I would never "correct" someone for calling it "UnitInterval", it's good enough -- but given this is a pure discussion of semantics...)

Sure, that's fair. I was more talking about it being better to name the type a particular thing, rather than encoding the type in the variable name.

    typedef float UnitIntervalValue;

    void do_something_accurately(UnitIntervalValue accuracy);
FTFY
UnitInterval isn't a type, it's a value of type Range, specifically the range [0,1].

UnitIntervalValue would be the type name for the thing we are interested in.

Values of that type should of course have descriptive names.

Creating a type that is defined as being between one and zero would be more helpful and then the name can reflect the usage of the value
Sure, but then you still have to name the type.
UnitInterval

Represent it internally as either fixed or floating point and divide to convert in and out if needed.

With a nice type system you could even genericize the type over integer constants

Others have already said it, but that name is for a type whose values are intervals, not a type whose values are numbers within an interval.
I like that the top-voted answer is a wrong one.

(A unit interval is the set [0, 1], whereas the asker wants to know a name for an element of it.)

Yeah, this is a pretty significant difference between a set and an element.
The fix is simple: Put the type of the variable in the type name. Then "UnitInterval proportion" tells you everything you need to know.
That's three words though, and the SO OP asked for a single word.
I like this idea of using the type name to define the domain, and variable name to define the purpose.
Names of types usually refer to individual members thereof: number, integer, vector, string, list… A variable of a UnitInterval type would one that holds unit intervals. This is no fix.
(comment deleted)
I guess this is like "mammal" vs "mammalia".
"Belongs to the unit interval" is correct, but I like to think most of us have gotten enough exposure to cognitive science to know that the brain prefers to have a word or adjective for everything, and that's the problem here.

Also, Unit Interval is only an answer to this exact question, not a class of questions to which this one belongs. If the range was [0,5] then you couldn't even shorten it with Unit Interval.

Is there a dictionary or thesaurus or something similar specifically designed to help programmers name things? I run into questions like this all the time. “There has to be a commonly used word for this concept, but I don’t know what it is”
Maybe there should be an IRC group #namingthings on Freenode?
Since they didn't want to document, I think `float Accuracy0to1` is a nice compromise that most people would understand instantly. Add `Incl` or `Excl` if you really need to disambiguate that.