Live data from Hacker News

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

english.stackexchange.com

101–110 of 325 posts

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

#101
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…

yeah, right, so what do you call such a type? I believe that is the actual question.

The question was about the parameter name, though. The correct answer seems to be:

    function FuncName(UnitInterval accuracy)

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

#102

Earlier quoted context omitted.

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 c…

> "percent" ... usually ranges from 0 to 1

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

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

#103
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…

That's a very good observation. We still could need a (new) term for this common type. Maybe floatbit, softbit, qubit(sic), pot, unitfloat, unit01 or just unitinterval as suggested?

This begs an interesting tangential question: Which programming languages allow such resticted intervals as types?

type percentage:=int[0,100] type hexdigit:=int[0,15] …

since this might be overkill, sane programming languages might encourage assert statements inside the functions.

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

#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)?

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

#105
post #99

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

I am trying to think of what the opposite word is of normalization.

In the spaces I work in, people just say denormalized / denormalization.

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

#107
post #55

Earlier quoted context omitted.

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);

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...)

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

#108
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.

Some languages provide more than just an alias. Eg Haskell lets you wrap your Float in a 'newtype' like 'GpsInMeters'.

The newtype wrapper doesn't show up at runtime, only at compile time. It can be set up in such a way that the compiler complains about adding GpsInMeters to GpsInMiles naively.

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

#109
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'm envisioning a programming language in which variable names and type names can become one.

So instead of

func call(Person person){} you just have func call(person){}

where person is a known type AND the variable name.

In that scenario 'accuracy' would be a type with known value between 0 and 1.

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

#110
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.

That's what unboxed tagged types are for. Floats (e.g.) at runtime, but with compile time restrictions.
Post reply on HN