Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //We are trying to find a mode estimation for a continuous
- //distributed set.
- //Anyway I am still working on a solution called 'half range method' and I came across a c# peculiarity.
- //I have a recursive binary search (essentially) and we are trying to
- //performance optimize it by instead of recreating the array of floats each pass,
- //use indices to narrow down the search.
- //Riddle me this:
- float test = input.Average();
- int count = (top - bottom) + 1;//number of elements in this iteration
- int pos = bottom;
- float average = 0f;//working average
- while (pos <= top)
- {
- average += input[pos];
- pos++;
- }
- average = average / count;
- //my average method returns 2 places less accuracy than c# .Average()
- //example:
- //0.0371166766 - c#
- //0.03711666 - my loop
- //125090.148 - c#
- //125090.281 - my loop
- //Any light you could shed on the subject would be much appreciated!
- //No rush.
- //Thanks in advance
- // - ST
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement