- If there are any similar scripts it would be interesting to know. Thanks.
- Note: If you split a range by n-tiles, you get n segments, n-1 values within the range, and n+1 values including the start/end of the range.
- E.g. if you split the range 0-100 into quartiles (4-tiles), you get 4 segments, 3 values with then range (25, 50, 75), and 5 values including the start/end of the range (0, 25, 50, 75, 100).
Code: Select all
q:: ;get all quantiles, or one quantile
oArray := JEE_Quantiles(0, 100, 4)
MsgBox, % JEE_ObjListSimple(oArray)
MsgBox, % JEE_Quantiles(0, 100, 4, 1)
oArray := JEE_Quantiles(1, 15, 7)
MsgBox, % JEE_ObjListSimple(oArray)
return
JEE_Quantiles(vFirst, vLast, vParts, vNum:="")
{
vDiff := vLast-vFirst
if !(vNum = "")
return vFirst + ((vDiff*vNum)/vParts)
oArray := []
Loop, % vParts + 1
oArray.Push(vFirst + ((vDiff*(A_Index-1))/vParts))
return oArray
}
JEE_ObjListSimple(oArray, vSep:=" ", vSep2:="`r`n")
{
for vKey, vValue in oArray
vOutput .= vKey vSep vValue vSep2
return SubStr(vOutput, 1, -StrLen(vSep2))
}