Class: Numo::GSL::Rstat::Quantile
- Inherits:
-
Object
- Object
- Numo::GSL::Rstat::Quantile
- Defined in:
- ext/numo/gsl/rstat/gsl_rstat.c
Class Method Summary collapse
-
.new(p) ⇒ Object
allocate instance of Quantile class.
Instance Method Summary collapse
-
#add(w) ⇒ Quantile
This function updates the estimate of the p-quantile with the new data point x.
-
#get ⇒ Float
This function returns the current estimate of the p-quantile.
-
#reset ⇒ Object
This function resets the workspace w to its initial state, so it can begin working on a new set of data.
Class Method Details
.new(p) ⇒ Object
allocate instance of Quantile class.
This function allocates a workspace for the dynamic estimation of p-quantiles, where p is between 0 and 1. The median corresponds to p = 0.5. The size of the workspace is O(1).
404 405 406 407 408 409 410 411 412 413 |
# File 'ext/numo/gsl/rstat/gsl_rstat.c', line 404
static VALUE
rstat_quantile_s_new(VALUE self, VALUE p)
{
gsl_rstat_quantile_workspace *w;
w = gsl_rstat_quantile_alloc(NUM2DBL(p));
if (!w) {
rb_raise(rb_eNoMemError,"fail to allocate struct");
}
return TypedData_Wrap_Struct(cQuantile, &rstat_quantile_data_type, (void*)w);
}
|
Instance Method Details
#add(w) ⇒ Quantile
This function updates the estimate of the p-quantile with the new data point x.
470 471 472 473 474 475 476 477 478 479 480 481 |
# File 'ext/numo/gsl/rstat/gsl_rstat.c', line 470
static VALUE
rstat_quantile_add(VALUE self, VALUE v1)
{
gsl_rstat_quantile_workspace *w;
ndfunc_arg_in_t ain[1] = {{cDF,0}};
ndfunc_t ndf = {iter_rstat_quantile_add, FULL_LOOP, 1,0, ain,0};
TypedData_Get_Struct(self, gsl_rstat_quantile_workspace, &rstat_quantile_data_type, w);
na_ndloop3(&ndf, w, 1, v1);
return self;
}
|
#get ⇒ Float
This function returns the current estimate of the p-quantile.
491 492 493 494 495 496 497 498 499 |
# File 'ext/numo/gsl/rstat/gsl_rstat.c', line 491
static VALUE
rstat_quantile_get(VALUE self)
{
gsl_rstat_quantile_workspace *w;
TypedData_Get_Struct(self, gsl_rstat_quantile_workspace, &rstat_quantile_data_type, w);
return DBL2NUM(gsl_rstat_quantile_get(w));
}
|
#reset ⇒ Object
This function resets the workspace w to its initial state, so it can begin working on a new set of data.
423 424 425 426 427 428 429 430 431 |
# File 'ext/numo/gsl/rstat/gsl_rstat.c', line 423
static VALUE
rstat_quantile_reset(VALUE self)
{
gsl_rstat_quantile_workspace *w;
TypedData_Get_Struct(self, gsl_rstat_quantile_workspace, &rstat_quantile_data_type, w);
gsl_rstat_quantile_reset(w);
return Qnil;
}
|