KDosanjh79 / Raspberry-Pi-sensor-project

indoor network sesnor project
0 stars 1 forks source link

Need help with the min, max and average #5

Open KDosanjh79 opened 7 years ago

KDosanjh79 commented 7 years ago

the file are on github called: K_Means_Simulation_Program.

I have attempted it yesterday and I couldn't get the average, minimum and maximum to work so I was hoping you could help me with this.

pedrombmachado commented 7 years ago

Hi @KDosanjh79 , Did you understand the algorithm that I gave you? You have 3 cluster composed of vectors with a size of 4. On Wednesday I have group them per cluster. Therefore you will need to compute the min, max and avg for each group. E.g. Assume that you have only 2 vectors (v1 and v2) in group 0: assume that v1=[1,2,3,4] and v2=[4,3,2,1] the resulting values should then be: min=[1,2,2,1] max=[4,3,3,4] avg=[2.5,2.5,2.5,2.5] In this case you could say conclude that cluster 0 his composed of values with an avg of 2.5 and with a variation from [1..4] for the first and fourth measures , [2..3] for the second and third measures. I believe that each one of the clusters will have a specific pattern that will be revealed with the min, max and avg. In terms of implementation you have to initialise the min with the maximum value (e.g 255, for a uint8) and the max and avg with 0. Then during the cycle you will need an if comparing the actual value with the min and max. For the avg you just need to accumulate all the values and then divide by the number of vectors in the cluster. E. g. in the previous the example the accumulator=[5,5,5,5] and then dividing by the number of vectors gives avg.