void variance_scaling_initializer::fill(AbsDistMat& matrix) {

  // Check if fan-in and fan-out parameters are valid
  if (m_fan_in <= 0 || m_fan_out <= 0) {
    std::stringstream err;
    err << "attempted variance scaling initialization "
        << "with invalid parameters "
        << "(fan_in=" << m_fan_in << ",fan_out=" << m_fan_out << ")";
    LBANN_ERROR(err.str());
  }

  // Get variance
  const auto& variance = get_variance(m_fan_in, m_fan_out);

  // Fill matrix with values drawn from probability distribution
  switch (m_prob_dist) {
  case probability_distribution::gaussian:
    gaussian_fill(matrix, matrix.Height(), matrix.Width(),
                  DataType(0), std::sqrt(variance));
    break;
  case probability_distribution::uniform:
    uniform_fill(matrix, matrix.Height(), matrix.Width(),
                 DataType(0), std::sqrt(3*variance));
    break;
  default:
    std::stringstream err;
    err << "variance scaling initializer is only supported with "
        << "Gaussian and uniform probability distributions "
        << "(dist=" << El::Int(m_prob_dist) << ")";
    LBANN_ERROR(err.str());
  }

}
Esempio n. 2
0
bool grid_cell::can_be_ignored() const
{
    if(get_variance() < 0.05 && get_estimated_value() < 0.05*active_survey_param::non_ros::target_threshold)
        return true;
    else
        return false;
}
Esempio n. 3
0
int get_variance_on_table(void * db, char * table_name, char * data)
{
    destroy_list_nbrs(MATH_LIST);
    MATH_LIST = create_list_nbrs();

    search_DB(db, table_name, data, math_callback);

    int variance = get_variance(MATH_LIST);

    return variance;
}
Esempio n. 4
0
int main(void) {
  int c, nl, nw, nc, state;
  int i, j;
  int word_initial, word_final, len;
  int word_length[MAXLEN];
  int numbers[MAXNWORD];

  for( i = 0 ; i < MAXLEN ; ++i ) {
    word_length[i] = 0;
  }
  for( i = 0 ; i < MAXNWORD ; ++i ) {
    numbers[i] = 0;
  }

  state = OUT;
  nl = nw = nc = 0;
  while( ( c = getchar() ) != EOF ) {
    ++nc;

    if( c == ' ' || c == '\n' || c == '\t' ) {
      if( state == IN ) {
	word_final = nc;
	len = word_final - word_initial;
	++word_length[len];

	numbers[nw] = (nl+1)*len;
	//	printf( "nw = %d, nl = %d, len = %d, numbers = %d\n", nw, nl, len, numbers[nw] );
	++nw;
      }
      state = OUT;
    }
    else if( state == OUT ) {
      state = IN;
      word_initial = nc;
    }

    if( c == '\n' ) {
      ++nl;
    }
  }

  printf( "#line = %d #word = %d #character = %d\n", nl, nw, nc );
  printf( "max = %d, avg = %.3f, var = %.3f\n", get_max( numbers, nw ),
	  get_average( numbers, nw ), get_variance( numbers, nw ) );

  bubble_sort(numbers, nw);

  return;
}
Esempio n. 5
0
double get_std_deviation(struct List_Nbrs * l)
{
    return sqrt(get_variance(l));
}
Esempio n. 6
0
/*
 * Now that an option and its argument have been read, validate them and
 * set the appropriate global configuration variables.
 */
static int
set_cfg_opt(char *cfg_option, char *cfg_arg)
  {
  char   *id = "set_cfg_opt";

  /* XXX Should smash case on these before doing string compares? */

  if (!strcmp(cfg_option, "TARGET_LOAD_PCT"))
    {
    schd_TARGET_LOAD_PCT = atoi(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "TARGET_LOAD_VARIANCE"))
    {
    return (get_variance(cfg_arg,
                         &schd_TARGET_LOAD_MINUS, &schd_TARGET_LOAD_PLUS));
    }

  if (!strcmp(cfg_option, "HIGH_SYSTIME"))
    {
    schd_HIGH_SYSTIME = atoi(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "MAX_JOBS"))
    {
    schd_MAX_JOBS = atoi(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "MIN_JOBS"))
    {
    schd_MIN_JOBS = atoi(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "MAX_DEDICATED_JOBS"))
    {
    schd_MAX_DEDICATED_JOBS = atoi(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "MAX_USER_RUN_JOBS"))
    {
    schd_MAX_USER_RUN_JOBS = atoi(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "ENFORCE_ALLOCATION"))
    {
    return schd_val2booltime(cfg_arg, &schd_ENFORCE_ALLOCATION);
    }

  if (!strcmp(cfg_option, "TEST_ONLY"))
    {
    return schd_val2bool(cfg_arg, &schd_TEST_ONLY);
    }

  if (!strcmp(cfg_option, "ENFORCE_DEDICATED_TIME"))
    {
    return schd_val2booltime(cfg_arg, &schd_ENFORCE_DEDTIME);
    }

  if (!strcmp(cfg_option, "DEDICATED_TIME_COMMAND"))
    {
    if (schd_DEDTIME_COMMAND)
      free(schd_DEDTIME_COMMAND);

    schd_DEDTIME_COMMAND = schd_strdup(cfg_arg);

    if (schd_DEDTIME_COMMAND == NULL)
      {
      log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id,
                 "schd_strdup(schd_DEDTIME_COMMAND)");
      return (-1);
      }

    return (0);
    }

  if (!strcmp(cfg_option, "DEDICATED_TIME_CACHE_SECS"))
    {
    schd_DEDTIME_CACHE_SECS = atoi(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "DECAY_FACTOR"))
    {
    schd_DECAY_FACTOR = atof(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "OA_DECAY_FACTOR"))
    {
    schd_OA_DECAY_FACTOR = atof(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "SCHED_ACCT_DIR"))
    {
    if (schd_SCHED_ACCT_DIR)
      free(schd_SCHED_ACCT_DIR);

    schd_SCHED_ACCT_DIR = schd_strdup(cfg_arg);

    if (schd_SCHED_ACCT_DIR == NULL)
      {
      log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id,
                 "schd_strdup(schd_SCHED_ACCT_DIR)");
      return (-1);
      }

    return (0);
    }

  if (!strcmp(cfg_option, "SYSTEM_NAME"))
    {
    if (schd_SYSTEM_NAME)
      free(schd_SYSTEM_NAME);

    schd_SYSTEM_NAME = schd_strdup(cfg_arg);

    schd_lowercase(schd_SYSTEM_NAME);

    return (0);
    }

  if (!strcmp(cfg_option, "SERVER_HOST"))
    {
    if (schd_SERVER_HOST)
      free(schd_SERVER_HOST);

    schd_SERVER_HOST = schd_strdup(cfg_arg);

    if (schd_SERVER_HOST == NULL)
      {
      log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id,
                 "schd_strdup(schd_SERVER_HOST)");
      return (-1);
      }

    schd_lowercase(schd_SERVER_HOST);

    return (0);
    }

  if (!strcmp(cfg_option, "SCHED_HOST"))
    {
    if (schd_SCHED_HOST)
      free(schd_SCHED_HOST);

    schd_SCHED_HOST = schd_strdup(cfg_arg);

    if (schd_SCHED_HOST == NULL)
      {
      log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id,
                 "schd_strdup(schd_SCHED_HOST)");
      return (-1);
      }

    schd_lowercase(schd_SCHED_HOST);

    return (0);
    }

  if (!strcmp(cfg_option, "SORTED_JOB_DUMPFILE"))
    {
    if (schd_JOB_DUMPFILE)
      free(schd_JOB_DUMPFILE);

    schd_JOB_DUMPFILE = schd_strdup(cfg_arg);

    if (schd_JOB_DUMPFILE == NULL)
      {
      log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id,
                 "schd_strdup(schd_JOB_DUMPFILE)");
      return (-1);
      }

    return (0);
    }

  if (!strcmp(cfg_option, "SCHED_RESTART_ACTION"))
    {
    if (strcmp(cfg_arg, "NONE") == 0)
      {
      schd_SCHED_RESTART_ACTION = SCHD_RESTART_NONE;
      return (0);
      }

    if (strcmp(cfg_arg, "RESUBMIT") == 0)
      {
      schd_SCHED_RESTART_ACTION = SCHD_RESTART_RESUBMIT;
      return (0);
      }

    if (strcmp(cfg_arg, "RERUN") == 0)
      {
      schd_SCHED_RESTART_ACTION = SCHD_RESTART_RERUN;
      return (0);
      }

    return (-1);  /* Bad argument */
    }

  if (!strcmp(cfg_option, "SORT_BY_PAST_USAGE"))
    {
    return schd_val2bool(cfg_arg, &schd_SORT_BY_PAST_USAGE);
    }

  if (!strcmp(cfg_option, "ENFORCE_PRIME_TIME"))
    {
    return schd_val2booltime(cfg_arg, &schd_ENFORCE_PRIME_TIME);
    }

  if (!strcmp(cfg_option, "PRIME_TIME_START"))
    {
    schd_PRIME_TIME_START = schd_val2sec(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "PRIME_TIME_END"))
    {
    schd_PRIME_TIME_END = schd_val2sec(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "PRIME_TIME_SMALL_NODE_LIMIT"))
    {
    schd_PT_SMALL_NODE_LIMIT = atoi(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "PRIME_TIME_SMALL_WALLT_LIMIT"))
    {
    schd_PT_SMALL_WALLT_LIMIT = schd_val2sec(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "PRIME_TIME_WALLT_LIMIT"))
    {
    schd_PT_WALLT_LIMIT = schd_val2sec(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "NONPRIME_DRAIN_SYS"))
    {
    return schd_val2bool(cfg_arg, &schd_NONPRIME_DRAIN_SYS);
    }

  if (!strcmp(cfg_option, "NP_DRAIN_BACKTIME"))
    {
    schd_NP_DRAIN_BACKTIME = schd_val2sec(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "NP_DRAIN_IDLETIME"))
    {
    schd_NP_DRAIN_IDLETIME = schd_val2sec(cfg_arg);
    return (0);
    }


  if (!strcmp(cfg_option, "SMALL_JOB_MAX"))
    {
    schd_SMALL_JOB_MAX = atoi(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "WALLT_LIMIT_LARGE_JOB"))
    {
    schd_WALLT_LARGE_LIMIT = schd_val2sec(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "WALLT_LIMIT_SMALL_JOB"))
    {
    schd_WALLT_SMALL_LIMIT = schd_val2sec(cfg_arg);
    return (0);
    }


  if (!strcmp(cfg_option, "MAX_QUEUED_TIME"))
    {
    schd_MAX_QUEUED_TIME = schd_val2sec(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "SMALL_QUEUED_TIME"))
    {
    schd_SMALL_QUEUED_TIME = schd_val2sec(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "INTERACTIVE_LONG_WAIT"))
    {
    schd_INTERACTIVE_LONG_WAIT = schd_val2sec(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "SUBMIT_QUEUE"))
    {
    arg_to_qlist(cfg_arg, ",", &schd_SubmitQueue);
    return (0);
    }

  if (!strcmp(cfg_option, "BATCH_QUEUES"))
    {
    arg_to_qlist(cfg_arg, ",", &schd_BatchQueues);
    return (0);
    }

  if (!strcmp(cfg_option, "SPECIAL_QUEUE"))
    {
    arg_to_qlist(cfg_arg, ",", &schd_SpecialQueue);
    return (0);
    }

  if (!strcmp(cfg_option, "DEDICATED_QUEUES"))
    {
    arg_to_qlist(cfg_arg, ",", &schd_DedQueues);
    return (0);
    }

  if (!strcmp(cfg_option, "EXTERNAL_QUEUES"))
    {
    arg_to_qlist(cfg_arg, ",", &schd_ExternQueues);
    return (0);
    }

  if (!strcmp(cfg_option, "FAKE_MACHINE_MULT"))
    {
    schd_FAKE_MACH_MULT = atoi(cfg_arg);
    return (0);
    }

  if (!strcmp(cfg_option, "AVOID_FRAGMENTATION"))
    {
    return schd_val2bool(cfg_arg, &schd_AVOID_FRAGS);
    }

  if (!strcmp(cfg_option, "MANAGE_HPM_COUNTERS"))
    {
    return schd_val2bool(cfg_arg, &schd_MANAGE_HPM);
    }

  if (!strcmp(cfg_option, "REVOKE_HPM_COUNTERS"))
    {
    return schd_val2bool(cfg_arg, &schd_REVOKE_HPM);
    }

  /* Unknown option -- return an error. */
  return (-1);
  }
Esempio n. 7
0
int work(void **inp, void **out) {
	int rcv_samples;
	int n;
	input_t *input;
	output_t *output;
	float gain_re,gain_im,variance,scale;
	_Complex float gain_c;

	if (!get_input_samples(0)) {
		return 0;
	}

	if (param_get_float(gain_re_id, &gain_re) != 1) {
		moderror("Error getting parameter gain_re\n");
		return -1;
	}
	if (param_get_float(gain_im_id, &gain_im) != 1) {
		moderror("Error getting parameter gain_im\n");
		return -1;
	}
	if (param_get_float(scale_id, &scale) != 1) {
		moderror("Error getting parameter scale\n");
		return -1;
	}
	if (!auto_mode) {
		if (param_get_float(variance_id, &variance) != 1) {
			moderror("Error getting parameter variance\n");
			return -1;
		}
	} else if (auto_mode == 1) {
		variance = get_variance(snr_current,scale);
		cnt_realizations++;
		if (cnt_realizations >= num_realizations) {
			snr_current += snr_step;
			cnt_realizations=0;
		}
		if (snr_current >= snr_max) {
			auto_mode=2;
			variance=0;
		}
	}

	__real__ gain_c = gain_re;
	__imag__ gain_c = gain_im;

	for (n=0;n<NOF_INPUT_ITF;n++) {
		input = inp[n];
		output = out[n];
		rcv_samples = get_input_samples(0);
		if (variance != 0) {
			gen_noise_c(noise_vec,variance,rcv_samples);
			vec_sum_c(output,input,noise_vec,rcv_samples);
		} else {
			memcpy(output,input,rcv_samples*sizeof(input_t));
		}
		if (gain_re != 1.0 && gain_im != 0.0) {
			vec_mult_c(output,output,gain_c,rcv_samples);
		}

	}
	return rcv_samples;
}
//-----------------------------------------------
double ConfidenceIntervalEstimator::get_sigma()
{
	if (!(M > 1)){ cout << "ConfidenceIntervalEstimator::get_sigma(): At least two observations are needed!"; exit(1); }

	return sqrt(get_variance());
}