コード例 #1
0
double unbiased_IQD(Eigen::VectorXd& v)
{
	double Q1 = break_down(v, 0.25);
	double Q3 = break_down(v, 0.75);
	return .7413*(Q3 - Q1); // The constant is such that
							// the IQD is unbiased when the
							// columns are normally distributed.
}
コード例 #2
0
ファイル: apop_text_to_db.c プロジェクト: biosmooth/Apophenia
int main(int argc, char **argv){
    char c, msg[1000];
    int colnames = 'y',
        rownames = 0,
        tab_exists_check = 0;
    char **field_names = NULL;
    apop_data *field_name_data, *field_name_data_t;

	sprintf(msg, "%s [-d delimiters] text_file table_name dbname\n"
                "e.g.: %s -d\",|\" infile.txt a_table info.db\n"
"If the input text file name is a single dash, -, then read from STDIN.\n"
"Input must be plain ASCII or UTF-8.\n"
"-d\t\tThe single-character delimiters to use, e.g., -d \" ,\" or -d \"\\t\" (which you \n"
"\t\t\twill almost certainly have to write as -d \"\\\\t\"). Default: \"| ,\\t\", meaning \n"
"\t\t\tthat any of a pipe, space, comma, or tab will delimit separate entries\n"
"-nc\t\tData does not include column names\n"
"-n regex\t\tCase-insensitive regular expression indicating Null values. Default: NaN \n"
"-m\t\tUse a mysql database (default: SQLite)\n"
"-f\t\tfixed width field ends: -f\"3,8,12,17\" (first char is one, not zero)\n"
"-u\t\tmysql username\n"
"-p\t\tmysql password\n"
"-r\t\tData includes row names\n"
"-v\t\tVerbose\n"
"-N\t\tA comma-separated list of column names: -N\"apple,banana,carrot,durian\"\n"
"-O\t\tIf table exists, erase it and write from scratch (i.e., Overwrite)\n"
"-h\t\tPrint this help\n\n"
, argv[0], argv[0]); 
    int * field_list = NULL;

	if(argc<3){
		printf("%s", msg);
		return 0;
	}
	while ((c = getopt (argc, argv, "n:d:f:hmp:ru:vN:O")) != -1)
        if (c=='n') {
              if (optarg[0]=='c')
			    colnames='n';
              else
                strcpy(apop_opts.db_nan, optarg);
        }
		else if (c=='N') {
            apop_regex(optarg, " *([^,]*[^ ]) *(,|$) *", &field_name_data);
            field_name_data_t = apop_data_transpose(field_name_data);
            field_names = field_name_data_t->text[0];
        }
        else if (c=='d') strcpy(apop_opts.input_delimiters, optarg);
		else if (c=='f') field_list = break_down(optarg);
		else if (c=='h') printf("%s", msg);
		else if (c=='m') apop_opts.db_engine = 'm';
		else if (c=='u') strcpy(apop_opts.db_user, optarg);
		else if (c=='p') strcpy(apop_opts.db_pass, optarg);
		else if (c=='r') rownames++;
		else if (c=='v') apop_opts.verbose=2;
		else if (c=='O') tab_exists_check++;
	apop_db_open(argv[optind + 2]);
    if (tab_exists_check) apop_table_exists(argv[optind+1],1);
    apop_query("begin;");
	apop_text_to_db(argv[optind], argv[optind+1], rownames, colnames, field_names, .field_ends=field_list);
    apop_query("commit;");
}
コード例 #3
0
double break_down(Eigen::VectorXd &v, double cutoff)
{
	std::vector<double> v2;
		v2.resize(v.count());
		for (int i = 0; i < v.count(); ++i)
			v2[i] = v(i);
	return break_down(v2,cutoff);
}
コード例 #4
0
int main(int argc, char **argv){
    char c, msg[1000];
    int colnames = 1,
        rownames = 0,
        tab_exists_check = 0;

	sprintf(msg, "%s [-d delimiters] text_file table_name dbname\n"
                "e.g.: %s -d\",|\" infile.txt a_table info.db\n"
"If the input text file name is a single dash, -, then read from STDIN.\n"
"Input must be plain ASCII or UTF-8.\n"
"-d\t\tThe single-character delimiters to use, e.g., -d \" ,\" or -d \"\\t\" (which you \n"
"\t\t\twill almost certainly have to write as -d \"\\\\t\"). Default: \"| ,\\t\", meaning \n"
"\t\t\tthat any of a pipe, space, comma, or tab will delimit separate entries\n"
"-nc\t\tData does not include column names\n"
"-n regex\t\tCase-insensitive regular expression indicating Null values. Default: NaN \n"
"-m\t\tUse a mysql database (default: SQLite)\n"
"-f\t\tfixed width field ends: -f\"3,8,12,17\" (first char is one, not zero)\n"
"-u\t\tmysql username\n"
"-p\t\tmysql password\n"
"-r\t\tData includes row names\n"
"-v\t\tVerbose\n"
"-O\t\tIf table exists, erase it and write from scratch (i.e., Overwrite)\n"
"-h\t\tPrint this help\n\n"
, argv[0], argv[0]); 
    int * field_list = NULL;

	if(argc<3){
		printf("%s", msg);
		return 0;
	}
	while ((c = getopt (argc, argv, "n:d:f:hmp:ru:vO")) != -1){
		switch (c){
		  case 'n':
              if (optarg[0]=='c')
			    colnames    --;
              else
                strcpy(apop_opts.db_nan, optarg);
			break;
		  case 'd':
			strcpy(apop_opts.input_delimiters, optarg);
			break;
		  case 'f':
            field_list = break_down(optarg);
            break;
		  case 'h':
			printf("%s", msg);
			return 0;
		  case 'm':
			apop_opts.db_engine = 'm';
            break;
		  case 'u':
			strcpy(apop_opts.db_user, optarg);
			break;
		  case 'p':
			strcpy(apop_opts.db_pass, optarg);
			break;
		  case 'r':
			rownames    ++;
			break;
		  case 'v':
			apop_opts.verbose ++;
			break;
		  case 'O':
            tab_exists_check    ++;
			break;
		}
	}
	apop_db_open(argv[optind + 2]);
    if (tab_exists_check) apop_table_exists(argv[optind+1],1);
    apop_query("begin;");
	apop_text_to_db(argv[optind], argv[optind+1], rownames,colnames, NULL, .field_ends=field_list);
    apop_query("commit;");
}