Esempio n. 1
0
// Creates a new generator for Levy-stable distribution, using an adaptive
// Gauss-Kronrod Integrator from the quad package.
//
// Default parameters are:
// 		eps_quad = integration target accuracy = 1e-14
//		eps_bisect = accuracy for locating max of integrand = 1e-10
//		limit_quad = integration iteration limit = 45
//		limit_bisect = bisection iteration limit = 50
func NewPdfZ() *PdfZ {

	eps_quad := 1e-14   // quadrature precision
	eps_bisect := 1e-10 // bisection precision
	alpha_tol := 1e-6   // tolerance for alpha to be close to special value (1 or 2)
	beta_tol := 1e-6    // tolerance for beta to be close to special value (0)
	limit_quad := 45    // quadrature iteration limit
	limit_bisect := 50  // bisection iteration limit
	q := quad.NewCustomQAG(quad.NewGaussKronrod61())
	return &PdfZ{eps_quad, eps_bisect, alpha_tol, beta_tol, limit_quad, limit_bisect, q}
}
Esempio n. 2
0
func TestPrintPdfMethods(t *testing.T) {

	fs := make([]plotter.XYs, 4)
	labels := make([]string, 4)

	pdf1 := NewCustomPdfZ(quad.NewSimpsonsRule(), 1e-10, 1e-10, 1e-6, 1e-6, 15, 50)
	fs[0] = plotutil.CreatePlotData(func(x float64) float64 {
		p, _ := Value(pdf1, x, 0.5, 0.5, 0.0, 1.0)
		return p
	}, -5.0, 5.0, 100)
	labels[0] = "Simpson"

	//	pdf2 := NewCustomPdfZ(quad.NewQAG(), 1e-14, 1e-10, 45, 50)
	pdf2 := NewPdfZ()
	fs[1] = plotutil.CreatePlotData(func(x float64) float64 {
		p, _ := Value(pdf2, x, 0.5, 0.5, 0.0, 1.0)
		return p
	}, -5.0, 5.0, 100)
	labels[1] = "Default QAG - GK21"

	pdf3 := NewCustomPdfZ(quad.NewCustomQAG(quad.NewGaussKronrod61()), 1e-14, 1e-10, 1e-6, 1e-6, 45, 50)
	fs[2] = plotutil.CreatePlotData(func(x float64) float64 {
		p, _ := Value(pdf3, x, 0.5, 0.5, 0.0, 1.0)
		return p
	}, -5.0, 5.0, 100)
	labels[2] = "Custom QAG - GK61"

	pdf4 := NewPdfBelov()
	fs[3] = plotutil.CreatePlotData(func(x float64) float64 {
		p, _ := Value(pdf4, x, 0.5, 0.5, 0.0, 1.0)
		return p
	}, -5.0, 5.0, 100)
	labels[3] = "Two integrands"

	plotutil.CreatePlot(fs, labels, map[string]string{"Title": "alpha_0.5_integrand_comp"})
}