![]() |
|
The odds and ends bin. Copyright (c) 2005--2007 by Ben Klemens. Licensed under the modified GNU GPL v2; see COPYING and COPYING2.
This function sorts the whole of a apop_data set based on one column. Sorts in place, with little additional memory used.
Uses the gsl_sort_vector_index function internally, and that function just ignores NaNs; therefore this function just leaves NaNs exactly where they lay.
| data | The input set to be modified. (No default, must not be NULL.) | |
| sortby | The column of data by which the sorting will take place. As usual, -1 indicates the vector element. (default: column zero of the matrix) | |
| asc | If 'd' or 'D', sort in descending order; else sort in ascending order. (Default: ascending) |
apop_data_show(apop_data_sort(d, -1)).This function uses the Designated initializers syntax for inputs.
| void apop_error | ( | int | level, | |
| char | stop, | |||
| char * | msg, | |||
| ... | ||||
| ) |
Inform the user of a faux pas. See also Apop_assert, which allows the function to return a value.
| level | At what verbosity level should the user be warned? E.g., if level==2, then print iff apop_opts.verbosity >= 2. You can set apop_opts.verbose==-1 to turn off virtually all messages, but this is probably ill-advised. | |
| stop | Either 's' or 'c', indicating whether the program should stop or continue. If stopping, uses assert(0) for easy debugging. You can use 'h' (halt) as a synonym for 's'. | |
| msg | The message to write to STDERR (presuming the verbosity level is high enough). This can be a printf-style format with following arguments. You can produce much more informative error messages this way, e.g., apop_error(0, 's', "Beta is %g but should be greater than zero.", beta);. |
| double apop_generalized_harmonic | ( | int | N, | |
| double | s | |||
| ) |
Calculate
| int apop_system | ( | const char * | fmt, | |
| ... | ||||
| ) |
Call system(), but with printf-style arguments. E.g.,
char filenames[] = "apop_asst.c apop_asst.o" apop_system("ls -l %s", filenames);
system() call. | double* apop_vector_percentiles | ( | gsl_vector * | data, | |
| char | rounding | |||
| ) |
Returns a vector of size 101, where returned_vector[95] gives the value of the 95th percentile, for example. Returned_vector[100] is always the maximum value, and returned_vector[0] is always the min (regardless of rounding rule).
| data | a gsl_vector of data. (No default, must not be NULL.) | |
| rounding | This will either be 'u', 'd', or 'a'. Unless your data is exactly a multiple of 101, some percentiles will be ambiguous. If 'u', then round up (use the next highest value); if 'd' (or anything else), round down to the next lowest value; if 'a', take the mean of the two nearest points. If 'u' or 'a', then you can say "5% or more of the sample is below returned_vector[5]"; if 'd' or 'a', then you can say "5% or more of the sample is above returned_vector[5]". (Default = 'd'.) |
This function uses the Designated initializers syntax for inputs.