testbed_api_sd.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. This file is part of GNUnet
  3. (C) 2008--2013 Christian Grothoff (and other contributing authors)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA.
  16. */
  17. /**
  18. * @file testbed/testbed_api_sd.h
  19. * @brief functions to calculate standard deviation
  20. * @author Sree Harsha Totakura <sreeharsha@totakura.in>
  21. */
  22. #ifndef TESTBED_API_SD_H
  23. #define TESTBED_API_SD_H
  24. /**
  25. * Opaque handle for calculating SD
  26. */
  27. struct SDHandle;
  28. /**
  29. * Initialize standard deviation calculation handle
  30. *
  31. * @param max_cnt the maximum number of readings to keep
  32. * @return the initialized handle
  33. */
  34. struct SDHandle *
  35. GNUNET_TESTBED_SD_init_ (unsigned int max_cnt);
  36. /**
  37. * Frees the memory allocated to the SD handle
  38. *
  39. * @param h the SD handle
  40. */
  41. void
  42. GNUNET_TESTBED_SD_destroy_ (struct SDHandle *h);
  43. /**
  44. * Add a reading to SD
  45. *
  46. * @param h the SD handle
  47. * @param amount the reading value
  48. */
  49. void
  50. GNUNET_TESTBED_SD_add_data_ (struct SDHandle *h, unsigned int amount);
  51. /**
  52. * Returns the factor by which the given amount differs from the standard deviation
  53. *
  54. * @param h the SDhandle
  55. * @param amount the value for which the deviation is returned
  56. * @param factor the factor by which the given amont differs
  57. * @return the deviation from the average; GNUNET_SYSERR if the deviation cannot
  58. * be calculated OR 0 if the deviation is less than the average; a
  59. * maximum of 4 is returned for deviations equal to or larger than 4
  60. */
  61. int
  62. GNUNET_TESTBED_SD_deviation_factor_ (struct SDHandle *h, unsigned int amount,
  63. int *factor);
  64. #endif
  65. /* end of testbed_api.h */