-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestRecoderFirstMethod.py
More file actions
42 lines (32 loc) · 1.32 KB
/
testRecoderFirstMethod.py
File metadata and controls
42 lines (32 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from fieldArray import *
from field import field
def most_frequent(List):
''' returns the mostFrequent item and frequency percentage'''
mostFrequentValue = 0
mostFrequentItem = List[0]
for i in List:
curr_frequency = List.count(i)
if(curr_frequency > mostFrequentValue):
mostFrequentValue = curr_frequency
mostFrequentItem = i
frequencyPercentage = mostFrequentValue / len(List)
return mostFrequentItem , frequencyPercentage
if __name__ == "__main__":
ARRAY_SIZE = 100
FIELD_SIZE = 10000
EXAMINATION_NUMBER = 10000
zeroExpected = 0
frequentExpected = 0
print(len([2,1,2]))
for i in range(EXAMINATION_NUMBER):
varJ = fieldArray(ARRAY_SIZE, FIELD_SIZE)
varJ.fillRandom()
# varJ.show()
zeroExpected += varJ.getExactDensity()
mostFrequentItem , frequencyPercentage = most_frequent(varJ.giveArraySimpleForm())
frequentExpected += frequencyPercentage
# print(most_frequent(varJ.giveArraySimpleForm()))
# print("Density is equal to: ", varJ.getExactDensity())
print("Expected zero Value :", (zeroExpected / EXAMINATION_NUMBER)*100,"%")
print("Ordinary zero Chance :", (1 / FIELD_SIZE)*100,"%")
print("New method upperbound Value :", (frequentExpected / EXAMINATION_NUMBER)*100,"%")