Polyfit
fit a polynomial
Defines | Enumerations | Functions | Variables
polygen.c File Reference

Polynomial data generator. More...

#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <inttypes.h>
#include <math.h>
#include <jwsc/base/error.h>
#include <jwsc/base/option.h>
#include <jwsc/vector/vector.h>
#include <jwsc/vector/vector_io.h>
#include <jwsc/matrix/matrix.h>
#include <jwsc/matrix/matrix_io.h>
#include <jwsc/matrix/matrix_math.h>
#include <jwsc/prob/pdf.h>
#include <jwsc/prob/mv_pdf.h>
#include <jwsc/stat/regress.h>

Go to the source code of this file.

Defines

#define NUM_OPTS_NO_ARG   2
#define NUM_OPTS_WITH_ARG   9
#define DEFAULT_SEED   289375
#define DEFAULT_SIGMA   1.0f
#define DEFAULT_DEGREE   1
#define DEFAULT_NUM_PTS   100
#define DEFAULT_W_MU   0.0
#define DEFAULT_W_SIGMA   0.1
#define DEFAULT_W_MIN   -2
#define DEFAULT_W_MAX   2
#define DEFAULT_X_MIN   -10
#define DEFAULT_X_MAX   10
#define DEFAULT_OUTLIER   0
#define DEFAULT_OUTLIER_SIGMA   6.0f

Enumerations

enum  { GAUSS = 0, UNIFORM }

Functions

static void print_usage (void)
 Prints the usage of the program.
static Errorprocess_help_opt (void)
 Processes the 'help' program options.
static Errorprocess_version_opt (void)
 Processes the 'version' program options.
static Errorprocess_seed_opt (Option_arg arg)
 Processes the 'seed' program options.
static Errorprocess_sigma_opt (Option_arg arg)
 Processes the 'sigma' program options.
static Errorprocess_degree_opt (Option_arg arg)
 Processes the 'degree' program options.
static Errorprocess_num_pts_opt (Option_arg arg)
 Processes the 'num-pts' program options.
static Errorprocess_w_gauss_opt (Option_arg arg)
 Processes the 'w-gauss' program options.
static Errorprocess_w_uni_opt (Option_arg arg)
 Processes the 'w-uni' program options.
static Errorprocess_x_range_opt (Option_arg arg)
 Processes the 'x-range' program options.
static Errorprocess_outlier_opt (Option_arg arg)
 Processes the 'outlier' program options.
static Errorprocess_outlier_sigma_opt (Option_arg arg)
 Processes the 'outlier-sigma' program options.
static void sample_w (Vector_d **w_out)
int main (int argc, const char **argv)
 Main function for the polygen program.

Variables

static Option_no_arg opts_no_arg [NUM_OPTS_NO_ARG]
 Program options taking no argument.
static Option_with_arg opts_with_arg [NUM_OPTS_WITH_ARG]
 Program options taking an argument.
static uint32_t seed = DEFAULT_SEED
 Random seed.
static float sigma = DEFAULT_SIGMA
 Sigma for generating points from the polynomial.
static uint32_t degree = DEFAULT_DEGREE
 Degree of the polynomial.
static uint32_t num_pts = DEFAULT_NUM_PTS
 Number of points to generate from the polynomial.
static float w_mu = DEFAULT_W_MU
 Mean value for w.
static float w_sigma = DEFAULT_W_SIGMA
 Standard variation value for w.
static float w_min = DEFAULT_W_MIN
 Minimum value for w.
static float w_max = DEFAULT_W_MAX
 Maximum value for w.
static float x_min = DEFAULT_X_MIN
 Minimum value for x.
static float x_max = DEFAULT_X_MAX
 Maximum value for x.
static float outlier = DEFAULT_OUTLIER
 Percentage of points to generate as outliers.
static float outlier_sigma = DEFAULT_OUTLIER_SIGMA
 Sigma for generating outlier points from the polynomial.
static enum { ... }  w_sample_t

Detailed Description

Polynomial data generator.

Author:
Joseph Schlecht
License:
Creative Commons BY-NC-SA 3.0

Definition in file polygen.c.


Define Documentation

#define NUM_OPTS_NO_ARG   2

Definition at line 66 of file polygen.c.

#define NUM_OPTS_WITH_ARG   9

Definition at line 67 of file polygen.c.

#define DEFAULT_SEED   289375

Definition at line 69 of file polygen.c.

#define DEFAULT_SIGMA   1.0f

Definition at line 70 of file polygen.c.

#define DEFAULT_DEGREE   1

Definition at line 71 of file polygen.c.

#define DEFAULT_NUM_PTS   100

Definition at line 72 of file polygen.c.

#define DEFAULT_W_MU   0.0

Definition at line 73 of file polygen.c.

#define DEFAULT_W_SIGMA   0.1

Definition at line 74 of file polygen.c.

#define DEFAULT_W_MIN   -2

Definition at line 75 of file polygen.c.

#define DEFAULT_W_MAX   2

Definition at line 76 of file polygen.c.

#define DEFAULT_X_MIN   -10

Definition at line 77 of file polygen.c.

#define DEFAULT_X_MAX   10

Definition at line 78 of file polygen.c.

#define DEFAULT_OUTLIER   0

Definition at line 79 of file polygen.c.

#define DEFAULT_OUTLIER_SIGMA   6.0f

Definition at line 80 of file polygen.c.


Enumeration Type Documentation

anonymous enum
Enumerator:
GAUSS 
UNIFORM 

Definition at line 125 of file polygen.c.


Function Documentation

static void print_usage ( void  ) [static]

Prints the usage of the program.

Definition at line 129 of file polygen.c.

static Error* process_help_opt ( void  ) [static]

Processes the 'help' program options.

Definition at line 138 of file polygen.c.

static Error* process_version_opt ( void  ) [static]

Processes the 'version' program options.

Definition at line 145 of file polygen.c.

static Error* process_seed_opt ( Option_arg  arg) [static]

Processes the 'seed' program options.

Definition at line 152 of file polygen.c.

static Error* process_sigma_opt ( Option_arg  arg) [static]

Processes the 'sigma' program options.

Definition at line 166 of file polygen.c.

static Error* process_degree_opt ( Option_arg  arg) [static]

Processes the 'degree' program options.

Definition at line 180 of file polygen.c.

static Error* process_num_pts_opt ( Option_arg  arg) [static]

Processes the 'num-pts' program options.

Definition at line 194 of file polygen.c.

static Error* process_w_gauss_opt ( Option_arg  arg) [static]

Processes the 'w-gauss' program options.

Definition at line 208 of file polygen.c.

static Error* process_w_uni_opt ( Option_arg  arg) [static]

Processes the 'w-uni' program options.

Definition at line 227 of file polygen.c.

static Error* process_x_range_opt ( Option_arg  arg) [static]

Processes the 'x-range' program options.

Definition at line 246 of file polygen.c.

static Error* process_outlier_opt ( Option_arg  arg) [static]

Processes the 'outlier' program options.

Definition at line 264 of file polygen.c.

static Error* process_outlier_sigma_opt ( Option_arg  arg) [static]

Processes the 'outlier-sigma' program options.

Definition at line 278 of file polygen.c.

static void sample_w ( Vector_d **  w_out) [static]

Definition at line 292 of file polygen.c.

int main ( int  argc,
const char **  argv 
)

Main function for the polygen program.

Definition at line 324 of file polygen.c.


Variable Documentation

Option_no_arg opts_no_arg[NUM_OPTS_NO_ARG] [static]

Program options taking no argument.

Definition at line 84 of file polygen.c.

Option_with_arg opts_with_arg[NUM_OPTS_WITH_ARG] [static]

Program options taking an argument.

Definition at line 87 of file polygen.c.

uint32_t seed = DEFAULT_SEED [static]

Random seed.

Definition at line 90 of file polygen.c.

float sigma = DEFAULT_SIGMA [static]

Sigma for generating points from the polynomial.

Definition at line 93 of file polygen.c.

uint32_t degree = DEFAULT_DEGREE [static]

Degree of the polynomial.

Definition at line 96 of file polygen.c.

uint32_t num_pts = DEFAULT_NUM_PTS [static]

Number of points to generate from the polynomial.

Definition at line 99 of file polygen.c.

float w_mu = DEFAULT_W_MU [static]

Mean value for w.

Definition at line 102 of file polygen.c.

float w_sigma = DEFAULT_W_SIGMA [static]

Standard variation value for w.

Definition at line 105 of file polygen.c.

float w_min = DEFAULT_W_MIN [static]

Minimum value for w.

Definition at line 108 of file polygen.c.

float w_max = DEFAULT_W_MAX [static]

Maximum value for w.

Definition at line 111 of file polygen.c.

float x_min = DEFAULT_X_MIN [static]

Minimum value for x.

Definition at line 114 of file polygen.c.

float x_max = DEFAULT_X_MAX [static]

Maximum value for x.

Definition at line 117 of file polygen.c.

float outlier = DEFAULT_OUTLIER [static]

Percentage of points to generate as outliers.

Definition at line 120 of file polygen.c.

float outlier_sigma = DEFAULT_OUTLIER_SIGMA [static]

Sigma for generating outlier points from the polynomial.

Definition at line 123 of file polygen.c.

enum { ... } w_sample_t [static]