# AccuratePoint

## Recommended Posts

Okay this started when I saw a graph (my homework) it need to find to upper bound and lower bound to get an accurate reading

Now how does work first lets say, 10 people voted 10 and 2 voted 1

(10+10+10+10+10+10+10+10+10+10+1+1)/12 = 8.5

But we all know that the other two are just the minority and does not play to role. And you will never get 10.

even 100 people vote 10 and only 10 people vote 1. its only comes to 9.1

This script is designed to remove the inaccurately

(10+10+10+10+10+10+10+10+10+10+1+1)/12 = 8.5 with my script it will point out that the average is 10, No AI purely MATH!!!

Average which is accurate by it self like 1 people voted 1 and 1 voted 10, this will give out 5 as the normal average as it does not have an accurate one.

Note: All function in the script (not include UDF) are written purely by me, You may use this in your application freely without clam that it's yours and no credit is needed.

```#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.0.0
Author:         Athiwat Chunlakhan

Script Function:
AccuratePoint

#ce ----------------------------------------------------------------------------

#include <Array.au3>

Global \$Number, \$average, \$Temp, \$upper, \$lower

\$Max = InputBox('Highest Vote', 'Enter Highest vote possible')
While 1
\$Temp = InputBox('Number', 'Press cancel when done')
If @error Then ExitLoop
WEnd
AddBound(\$Number);Put the number of number in \$Number
\$average = GetAverage(\$Number);Get normal average
MsgBox(0, 'Normal Average', GetAverage(\$Number))
\$upper = GetUpperBound(\$average, \$Max);Get upper bound 25% based     Note: you only one value so we can't do normal upper/lower bound
\$lower = GetlowerBound(\$average, \$Max);Get lower bound 25% based
RemoveInAccurate(\$Number, \$lower, \$upper);Start to remove InAccurate
If \$Number = 0 Then
MsgBox(0, 'Normal(already accurate)', \$average);If it is accurate it will not have a result so use normal average
Else
MsgBox(0, 'Use AccuratePoint', GetAverage(\$Number));If it is InAccurate it will have an result
EndIf

;UDF START ; By Athiwat Chunlakhan
Func AddBound(ByRef \$Array) ; \$Number represent the number of number
\$Number = UBound(\$Number) - 1
Func GetAverage(\$Array)
Local \$average
For \$i = 1 To UBound(\$Number) - 1
\$average += \$Number[\$i]
Next
\$average /= \$Number
Return \$average
EndFunc   ;==>GetAverage
Func GetUpperBound(\$Number, \$Max)
Local \$Temp
\$Temp = \$Number + (\$Max * 25) / 100
Return \$Temp
EndFunc   ;==>GetUpperBound
Func GetlowerBound(\$Number, \$Max)
Local \$Temp
\$Temp = \$Number - (\$Max * 25) / 100
Return \$Temp
EndFunc   ;==>GetlowerBound
Func IsInBetween(\$Number, \$lower, \$upper)
If \$Number > \$lower And \$Number < \$upper Then
Return 1
Else
Return 0
EndIf
EndFunc   ;==>IsInBetween
Func RemoveInAccurate(ByRef \$Number, \$lower, \$upper)
For \$i = 1 To UBound(\$Number) - 1
If Not IsInBetween(\$Number[\$i], \$lower, \$upper) Then
\$Number[\$i] = 0
\$Number -= 1
EndIf
Next
EndFunc   ;==>RemoveInAccurate
ÌÎNÒYÚÝÝIÌÎNË  ÌÎNÑ[YÚÝÝHÜÜÚXIÌÎNÊBÚ[HB   ÌÍÕ[H[]Þ
ÌÎNÓ[XÌÎNË    ÌÎNÔÜÈØ[Ù[Ú[ÛIÌÎNÊBYÜ[^]ÛÜÐ^PY
ÌÍÓ[X    ÌÍÕ[
BÑ[XØÝ]TÚ[
ÌÍÓ[X    ÌÍÓX^
B[ÈXØÝ]TÚ[
ÌÍÓ[X    ÌÍÓX^
BØØ[  ÌÍØ]YÙK ÌÍÝ  ÌÍÛÝÙIÌÍÓ[XÌHHPÝ[
ÌÍÓ[XHHBÜ   ÌÍÚHHHÈPÝ[
ÌÍÓ[XHHB ÌÍØ]YÙH
ÏH ÌÍÓ[XÉÌÍÚWB^ ÌÍØ]YÙHÏH  ÌÍÓ[XÌB ÌÍÝH ÌÍÓ[X
È
ÌÍÓX^
JHÈL   ÌÍÛÝÙH ÌÍÓ[XH
ÌÍÓX^
JHÈLÜ ÌÍÚHHHÈPÝ[
ÌÍÓ[XHHBYÝ
ÌÍÓ[X    ÝÈ    ÌÍÛÝÙ[ ÌÍÓ[X    È  ÌÍÝH[    ÌÍÓ[XÉÌÍÚWHH ÌÍÓ[XÌHOHB[Y^Y  ÌÍÓ[XÌHH[]  ÌÍØ]YÙB[ÙBÜ   ÌÍÚHHHÈPÝ[
ÌÍÓ[XHHB ÌÍØ]YÙH
ÏH ÌÍÓ[XÉÌÍÚWB^ ÌÍØ]YÙHÏH  ÌÍÓ[XÌB]    ÌÍØ]YÙB[Y[[ÈÏOIÝÐXØÝ]TÚ[```

This version work with all number even a very large one, fixed the math.

Edited by athiwatc
##### Share on other sites

why not using one function?

```Func Median(\$Number)
Local \$average, \$upper, \$lower
For \$i = 1 To UBound(\$Number) - 1
\$average += \$Number[\$i]
Next
\$average /= \$Number

\$upper = \$Number + (\$Number * 25) / 100
\$lower = \$Number - (\$Number * 25) / 100

For \$i = 1 To UBound(\$Number) - 1
If Not (\$Number > \$lower And \$Number < \$upper) Then
\$Number[\$i] = 0
\$Number -= 1
EndIf
Next

If \$Number = 0 Then
Return \$average
Else
For \$i = 1 To UBound(\$Number) - 1
\$average += \$Number[\$i]
Next
\$average /= \$Number
Return \$average
EndIf
EndFunc   ;==>Median```

makes handling much easyer.

```\$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For \$b=1 To UBound(\$a)+(-1*-1*-1)step(2^4/8);&\$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec(\$a[\$b]&\$a[\$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get\$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)```
##### Share on other sites

why not using one function?

```Func Median(\$Number)
Local \$average, \$upper, \$lower
For \$i = 1 To UBound(\$Number) - 1
\$average += \$Number[\$i]
Next
\$average /= \$Number

\$upper = \$Number + (\$Number * 25) / 100
\$lower = \$Number - (\$Number * 25) / 100

For \$i = 1 To UBound(\$Number) - 1
If Not (\$Number > \$lower And \$Number < \$upper) Then
\$Number[\$i] = 0
\$Number -= 1
EndIf
Next

If \$Number = 0 Then
Return \$average
Else
For \$i = 1 To UBound(\$Number) - 1
\$average += \$Number[\$i]
Next
\$average /= \$Number
Return \$average
EndIf
EndFunc   ;==>Median```

makes handling much easyer.

That's making sure that \$Number has a  index containing the amount of values.
##### Share on other sites

...(10+10+10+10+10+10+10+10+10+10+1+1)/12 = 8.5 with my script it will point out that the average is 10,...

Ah, now I see how the government in the UK at least works out their statistics! So if I have 12 glasses of beer, 10 are full and 2 are 10% full, then I can redistribute the beer so that all 12 glasses are full. because the average is 100% full. That's great, there's money to be made here.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
##### Share on other sites

Perhaps it could be used in an application that collects data, and we've all seen when you get a result that is way out in left field that would throw off your calculations if you included it in your data set.

Giggity

##### Share on other sites

Ah, now I see how the government in the UK at least works out their statistics! So if I have 12 glasses of beer, 10 are full and 2 are 10% full, then I can redistribute the beer so that all 12 glasses are full. because the average is 100% full. That's great, there's money to be made here.

No wonder they can claim £18,000 for some bookshelves, they're using this...
##### Share on other sites

Ah, now I see how the government in the UK at least works out their statistics! So if I have 12 glasses of beer, 10 are full and 2 are 10% full, then I can redistribute the beer so that all 12 glasses are full. because the average is 100% full. That's great, there's money to be made here.

Nice one, but this is suppose to be use in a voting system to take out all spammer that like to vote 1 for no reason.

And yes the MODE of "12 glasses of beer, 10 are full and 2 are 10% full" is 100% full.

This combine MODE with AVERAGE because MODE will never work in a voting system, 50 people vote 5, 51 people vote 4, the result is 4.

But with average say, 5 people voted 1, the result will be about 4.3

If we combine both the result will be about 4.5 which is fair cause 1 is just 5 people compare to 101 people. We will see much better result when more people is voting.

Edited by athiwatc
##### Share on other sites

why not using one function?

```Func Median(\$Number)
Local \$average, \$upper, \$lower
For \$i = 1 To UBound(\$Number) - 1
\$average += \$Number[\$i]
Next
\$average /= \$Number

\$upper = \$Number + (\$Number * 25) / 100
\$lower = \$Number - (\$Number * 25) / 100

For \$i = 1 To UBound(\$Number) - 1
If Not (\$Number > \$lower And \$Number < \$upper) Then
\$Number[\$i] = 0
\$Number -= 1
EndIf
Next

If \$Number = 0 Then
Return \$average
Else
For \$i = 1 To UBound(\$Number) - 1
\$average += \$Number[\$i]
Next
\$average /= \$Number
Return \$average
EndIf
EndFunc   ;==>Median```

makes handling much easyer.

The main reason is for other people to use the UDF also but okay. I posted in my first post with the fix mention in the post be low you. (if you want me to remove just tell)
##### Share on other sites

The main reason is for other people to use the UDF also but okay. I posted in my first post with the fix mention in the post be low you. (if you want me to remove just tell)

thats fine with me :-)

btw i thought it was median, always wanted it to have in autoit, would it be possible for you to write a median udf? i tried several times but i m not good in reading formulas.

```\$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For \$b=1 To UBound(\$a)+(-1*-1*-1)step(2^4/8);&\$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec(\$a[\$b]&\$a[\$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get\$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)```
##### Share on other sites

Okay there is a MATH ERROR (\$Number * 25) / 100 is not a constant and will favor higher number so it suppose to be (\$Max * 25) / 100 where MAX is the highest possible vote score.

Fixed in the first post.

Edited by athiwatc
##### Share on other sites

thats fine with me :-)

btw i thought it was median, always wanted it to have in autoit, would it be possible for you to write a median udf? i tried several times but i m not good in reading formulas.

Here is your Median function hope you like it.

```#include <Array.au3>
Global \$Number

While 1
\$Temp = InputBox('Number to find the median', 'Press cancel when done')
If @error Then ExitLoop
WEnd

MsgBox(0,'',Median(\$Number))

Func Median(\$Number)
_ArraySort(\$Number)
\$Number = UBound(\$Number) - 1
\$Middle = (\$Number + 1) / 2
If IsInt (\$Middle) Then
Return \$Number[\$Middle]
Else
Return (\$Number[\$Middle-0.5]+\$Number[\$Middle+0.5])/2
EndIf
EndFunc```
##### Share on other sites

thank you very much, can use it with our bandwidth stability tests

Edited by JRSmile
```\$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For \$b=1 To UBound(\$a)+(-1*-1*-1)step(2^4/8);&\$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec(\$a[\$b]&\$a[\$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get\$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)```
##### Share on other sites

Another use for this is ploting data. if your data should resemble a curve when ploted and one point is out in the middle of no where then it messes things up.

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...