class ApacheCrunch::ConfidenceInterval

DSL routine that determines a confidence interval for the values to which the block evaluates

For example,

confidence_interval 95 do
    time_to_serve
end

would return two numbers, the lower and upper bound of a 95% confidence interval for the values of time_to_serve.

This routine returns a float, and the block must always evaluate to something with a to_f method.

Public Instance Methods

execute(confidence, &blk) click to toggle source
# File lib/procedure_dsl.rb, line 216
def execute(confidence, &blk)
    # Build a list of all the values found
    values = []
    while @_current_entry = @_log_parser.next_entry
        values << instance_eval(&blk).to_f
    end
    values.sort!

    # Determine how many values are outside the bounds of the CI
    count_outside = (values.length * (1.0 - confidence/100.0)).to_i

    # Find the bounds of the confidence interval
    return values[count_outside / 2], values[-count_outside / 2]
end