Skip to content

dist #

Probability Distributions algorithms

This module provides functions for computing probability distributions.

fn build_text_hist #

fn build_text_hist(xmin f64, xmax f64, nstations int, values []f64, numfmt string, barlen int) !string

build_text_hist builds a text histogram

fn text_hist #

fn text_hist(labels []string, counts []int, barlen int) !string

text_hist prints a text histogram

fn Histogram.new #

fn Histogram.new(stations []f64) &Histogram

Histogram.new returns an histogram struct from a given list of stations

struct Histogram #

struct Histogram {
pub mut:
	stations []f64 // stations
	counts   []int // counts
}

fn (Histogram) find_bin #

fn (o Histogram) find_bin(x f64) !int

find_bin finds where x falls in returns -1 if x is outside the range

fn (Histogram) count #

fn (mut o Histogram) count(vals []f64, clear bool) !

count counts how many items fall within each bin

fn (Histogram) gen_labels #

fn (o Histogram) gen_labels(numfmt string) ![]string

gen_labels generate nice labels identifying bins

fn (Histogram) density_area #

fn (o Histogram) density_area(nsamples int) !f64

density_area computes the area of the density diagram nsamples -- number of samples used when generating pseudo-random numbers