Live data from Hacker News

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

english.stackexchange.com

321–325 of 325 posts

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

#321
post #316

Earlier quoted context omitted.

Or you could approach it another way, store the data using the full range of the system float type and normalize it to [0,1] through accessor methods. Can float types even support 0, 1 inclusive? You just can't represent natural numbers like that with floats...

The main issue with techniques such as this, which are certainly easy to do, is that if it’s not in the type system and therefore not checked at compile time, you pay a run time cost for these abstractions.

You can't represent the interval from 0 to 1 inclusive without significant run time cost just because of the way floats work.

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

#322

"Probability". This question would have a single word answer if it was posted on math.stackexchange.com. literally copy/pasted from wikipedia: > A probability is a way of assigning every event a value between zero and one,

A probability has to lie between 0 and 1 but not every value between 0 and 1 is a probability.

the probability of a "value between 0 and 1" to be an actual probability is very close to 1.

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

#323
post #55

Earlier quoted context omitted.

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

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.

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

#324

Earlier quoted context omitted.

Is there an example, in any language, showing how you would represent this at the type level? I can’t see how you would do it.

You would just make the constructor return a possible error if it's not in range, or maybe some specialty constructors that may clamp it into range for you so they always succeed. It's the same question of, how can you convert a string to a Regexp type if not all strings are valid Regexps?

Right, so there's no way to do this:

> In other words, the parameter should not be a float, but a more constrained type that allows floats only in [0,1]

It's a value check, not a type check.

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

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

Is there an example, in any language, showing how you would represent this at the type level? I can’t see how you would do it.

[deleted]
Post reply on HN