Live data from Hacker News

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

english.stackexchange.com

281–290 of 325 posts

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

#281

Earlier quoted context omitted.

I agree that it's a question of type: what would you call that type though? I propose "pun" - proportion of unity, or "p(er) un".

Between0And1Inclusive I like verbosity! Or use a dependent type language. Maybe Idris? Then something like Between(0,1) I guess.

Nothing wrong with the name ZeroToOneInclusive. Seems like a great type to have around, and a great name for it. UnitFloat or UnitIntervalFloat or other ideas ITT are cuter but not much clearer.

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

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

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?

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

#285
post #121

Earlier quoted context omitted.

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?

> While true, if your language doesn’t support such a type You'd be surprised where the support is. In C#, you would declare a struct type with one read only field of type double, and range validation (x this is the "value object" pattern. http://wiki.c2.com/?ValueObject Yes there's a bit of boilerplate - especially since you might want to override equality, cast operators etc. But there is support. And with a struct…

I don't think runtime validation is that special. You can bend most languages into this pattern one way or another. The real deal is having an actual compile-time-checked type that resembles a primitive.

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

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

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

In Swift you can achieve this with Property Wrappers:

  @Clamping(0...14) var pH: Double = 7.0
https://nshipster.com/propertywrapper/#implementing-a-value-...

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

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

Even if you could created constrained types like this, don't you still need to worry about what to call it?

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

#288
post #285

Earlier quoted context omitted.

> While true, if your language doesn’t support such a type You'd be surprised where the support is. In C#, you would declare a struct type with one read only field of type double, and range validation (x this is the "value object" pattern. http://wiki.c2.com/?ValueObject Yes there's a bit of boilerplate - especially since you might want to override equality, cast operators etc. But there is support. And with a struct…

I don't think runtime validation is that special. You can bend most languages into this pattern one way or another. The real deal is having an actual compile-time-checked type that resembles a primitive.

Actually what I want is just the reading experience of seeing

"public Customer GetById(CustomerId id)" instead of "public Customer GetById(string id)" when only some strings (e.g. 64 chars A-Z and 1-9) are valid customer ids.

Compile-time validation would be ideal, but validation at the edges, well before that method, is good enough.

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

#289

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

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.

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

#290
post #123

If 0-100 is a percent, then wouldn't 0-1 be a perun(something)? I don't know latin, but perun, perune, peruni?

Perunage, yes. Lamentably that is not restricted to [0,1], just as a percentage isn't restricted to [0%, 100%] (look at the stock market return over the last few days, and the last decade).
Post reply on HN