I am writing a package for some survey sampling stuff, related to stratification. In all related formulas, the following statistical features are used:
Nfor population size
nfor sample size from the population
Nhfor the size of the
nhfor the sample size from the
In wrote similar programs in several other languages, and I always used the corresponding naming convention for variables representing the above features:
For anyone knowing the stratification stuff (what the algorithms are all about) this would be clear as sun. Now, how to do this in Go? I cannot use small
n, but I must differentiate between
N. I can make it
SampleN, though it’s rather wordy. But what about differentiating slices
n_h? I should not be using underscores, so I I would make them
SampleNh, though both have capital
N though the all the formulas make a clear distinction between
N (for population size) and
n (for sample size).
I have been working with this stuff for over 15 years and I think I should do fine with the following four variable names:
SampleNh, but they will not read naturally and for the very first time a language’s naming convention makes variable names sound unnatural.
SampNh? Do not read well. So maybe even
Snh? Nope, these won’t do:
P stands for proportion and
S stands for standard deviation (and I am talking about the corresponding formulas, not just generally about statistics). Thus I think I should use the longer names, though the shortest version has one advantage: I am differentiating capital and lower “n”, something representing the actual names in the statistical formulas. But I don’t think this would work in
Samplenh, since they do not read well. Unless I would do them
Sample_nh…? But this is like selling the same information twice, and so the prefixes (
Sample_) are redundant, being there only because I cannot start a variable’s name with a lower letter.
Are there any situations in which I could break Go’s naming convention, like that of not using the underscore? Or maybe you have some ideas how to make these particular names better? I understand this is a peculiar situation because I need to find the representation in Go of formulas in which
n differs from
N, something I cannot directly do in Go.
Sure, I can use various names, like above, but I always pay much attention to good naming, one that well represents the phenomenon (here, statistical formulas) and that at the same time reads well.
Hm, last thought: maybe
_nh will do?