128 while (NULL != (entry =
h->head))
151 if (
h->cnt ==
h->max_cnt)
157 ((
unsigned long) entry->
amount) * ((
unsigned long) entry->
amount);
167 h->avg = ((float)
h->sum) / ((float)
h->cnt);
168 h->sqsum += ((
unsigned long)
amount) * ((
unsigned long)
amount);
169 sqsum_avg = ((double)
h->sqsum) / ((double)
h->cnt);
170 sqavg = ((double)
h->avg) * ((double)
h->avg);
171 h->vr = sqsum_avg - sqavg;
196 diff = ((float)
amount) -
h->avg;
201 diff =
h->avg - ((float)
amount);
205 for (n = 1; n < 4; n++)
206 if (diff < (((
double) (n * n)) *
h->vr))
static struct GNUNET_ARM_Handle * h
Connection with ARM.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
An entry to hold data which will be used to calculate SD.
struct SDEntry * next
DLL next pointer.
unsigned int amount
The value to store.
struct SDEntry * prev
DLL prev pointer.
Opaque handle for calculating SD.
unsigned int max_cnt
max number of entries we can have in the DLL
struct SDEntry * head
DLL head for storing entries.
struct SDEntry * tail
DLL tail for storing entries.
float avg
The average of data amounts.
unsigned long sum
Sum of the data values.
unsigned int cnt
Number of data values; also the length of DLL containing SDEntries.
unsigned long long sqsum
Squared sum of data values.
int GNUNET_TESTBED_SD_deviation_factor_(struct SDHandle *h, unsigned int amount, int *factor)
Calculates the factor by which the given amount differs.
struct SDHandle * GNUNET_TESTBED_SD_init_(unsigned int max_cnt)
Initialize standard deviation calculation handle.
void GNUNET_TESTBED_SD_destroy_(struct SDHandle *h)
Frees the memory allocated to the SD handle.
void GNUNET_TESTBED_SD_add_data_(struct SDHandle *h, unsigned int amount)
Add a reading to SD.
functions to calculate standard deviation