Live data from Hacker News

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

english.stackexchange.com

121–130 of 325 posts

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

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

While true, if your language doesn’t support such a type, then the burden for such a name goes to the parameter, does it not?

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

#122

Earlier quoted context omitted.

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.

what if you have to deal with two persons?

In that case you could have the signature

func call(person#1 person#2){}

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

#124
post #82
post #68

Earlier quoted context omitted.

percentage is 0 to 100, though. (Or even more, saying 200% is not technically wrong depending on context)

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.

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

#126
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've used "fraction" for this purpose .. but that isn't general enough. In fact a convention I've used for nearly 2 decades has been varName_unit .. where the part after the underscore (with the preceding part being camel case) indicates the unit of the value. So (x_frac, y_frac) are normalized screen coordinates whereas (x_px, y_px) would be pixel unit coordinates. Others are like freq_hz, duration_secs and so on.

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

#127

Earlier quoted context omitted.

The question was about the parameter name , though. The correct answer seems to be: function FuncName(UnitInterval accuracy)

UnitInterval seems to contains an interval , not a single float. I don't think it's a very good name. UnitIntervalNumber would be better, but it's too long. Something like UnitNumber or UnitFloat could maybe work.

After reading this reply twice, I realised you are right and UnitInterval type indicates an interval object instead of a single scalar number.

I have actually used intervals, and should have realised this sooner. But I just had my first cup of coffee...

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

#128

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

I use this term for https://github.com/VCVRack/Rack. Sometimes I say "`x` is a normalized float between 0 to 1" to somewhat reveal the definition of the term.

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

#129
post #74
post #45

Earlier quoted context omitted.

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.

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.
Post reply on HN