Exemplo n.º 1
0
Arquivo: print.go Projeto: enodev0/rat
// StdOutput is responsible for doing the actual printing to STDOUT, based on certain
// arguments which it receives.
func StdOutput(mode string, r reg.New, xquery, yquery float64, plot bool) {

	fmt.Println("*********************************************************")
	switch mode {
	case "all":
		fmt.Printf("Query(YonX for %f):\t\t\t%f\n", yquery, r.ModelYX(yquery))
		fmt.Printf("Query(XonY for %f):\t\t\t%f\n", xquery, r.ModelXY(xquery))
		fmt.Printf("Equation(YonX):\t\t\t\t%s\n", r.Equation("YonX"))
		fmt.Printf("Equation(XonY):\t\t\t\t%s\n", r.Equation("XonY"))
		fmt.Printf("Confidence:\t\t\t\t\t%.2f%%\n", r.Conf()) // ??
		x, y := r.Intersect()
		fmt.Printf("Intersect:\t\t\t\t(%f,%f)\n", x, y)
		fmt.Printf("Regression Coeff(YonX):\t\t\t\t%f\n", r.Byx())
		fmt.Printf("Regression Coeff(XonY):\t\t\t\t%f\n", r.Bxy())
		fmt.Printf("Covariance:\t\t\t\t\t%f\n", r.Covariance())
		fmt.Printf("StdDev(Y):\t\t\t\t\t%f\n", r.SdY())
		fmt.Printf("StdDev(X):\t\t\t\t\t%f\n", r.SdX())
	case "YX":
		fmt.Printf("Query(YonX for %f):\t\t\t%f\n", yquery, r.ModelYX(yquery))
		fmt.Printf("Equation(YonX):\t\t\t\t%s\n", r.Equation("YonX"))
		fmt.Printf("Confidence:\t\t\t\t\t%.2f%%\n", r.Conf()) // ??
		fmt.Printf("Regression Coeff(YonX):\t\t\t\t%f\n", r.Byx())
		fmt.Printf("Covariance:\t\t\t\t\t%f\n", r.Covariance())
		fmt.Printf("StdDev(Y):\t\t\t\t\t%f\n", r.SdY())
	case "XY":
		fmt.Printf("Query(XonY for %f):\t\t\t%f\n", xquery, r.ModelXY(xquery))
		fmt.Printf("Equation(XonY):\t\t\t%s\n", r.Equation("XonY"))
		fmt.Printf("Confidence:\t\t\t\t\t%.2f%%\n", r.Conf()) // <-- not matching
		fmt.Printf("Regression Coeff(XonY):\t\t\t\t%f\n", r.Bxy())
		fmt.Printf("Covariance:\t\t\t\t\t%f\n", r.Covariance())
		fmt.Printf("StdDev(X):\t\t\t\t\t%f\n", r.SdX())
	default:
		break

	}
	fmt.Println("*********************************************************")
	if plot {
		fmt.Printf("%sOpen the .html file in your browser to render the plot%s", yellow, reset)
	}
}
Exemplo n.º 2
0
Arquivo: write.go Projeto: enodev0/rat
// Standard prints out statistics to a file on disk
func Standard(mode string, r reg.New, file string, writeAddr io.Writer, xquery, yquery float64) {
	if len(file) == 0 {
		fmt.Fprintf(writeAddr, "Results for: Unknown file\n")
	} else {
		fmt.Fprintf(writeAddr, "Results for: %s\n", file)
	}
	fmt.Fprintf(writeAddr, "*********************************************************\n")
	switch mode {
	case "all":
		fmt.Fprintf(writeAddr, "Query(YonX for %f):\t\t\t%f\n", yquery, r.ModelYX(yquery))
		fmt.Fprintf(writeAddr, "Query(XonY for %f):\t\t\t%f\n", xquery, r.ModelXY(xquery))
		fmt.Fprintf(writeAddr, "Equation(YonX):\t\t\t\t%s\n", r.Equation("YonX"))
		fmt.Fprintf(writeAddr, "Equation(XonY):\t\t\t\t%s\n", r.Equation("XonY"))
		fmt.Fprintf(writeAddr, "Confidence:\t\t\t\t\t%.2f%%\n", r.Conf()) // <-- not matching
		x, y := r.Intersect()
		fmt.Fprintf(writeAddr, "Intersect:\t\t\t\t\t(%.1f,%.1f)\n", x, y)
		fmt.Fprintf(writeAddr, "Regression Coeff(YonX):\t\t\t\t%f\n", r.Byx())
		fmt.Fprintf(writeAddr, "Regression Coeff(XonY):\t\t\t\t%f\n", r.Bxy())
		fmt.Fprintf(writeAddr, "Covariance:\t\t\t\t\t%f\n", r.Covariance())
		fmt.Fprintf(writeAddr, "StdDev(Y):\t\t\t\t\t%f\n", r.SdY())
		fmt.Fprintf(writeAddr, "StdDev(X):\t\t\t\t\t%f\n", r.SdX())
	case "YX":
		fmt.Fprintf(writeAddr, "Query(YonX for %f):\t\t\t%f\n", yquery, r.ModelYX(yquery))
		fmt.Fprintf(writeAddr, "Equation(YonX):\t\t\t\t%s\n", r.Equation("YonX"))
		fmt.Fprintf(writeAddr, "Confidence:\t\t\t\t\t%.2f%%\n", r.Conf()) // <-- not matching
		fmt.Fprintf(writeAddr, "Regression Coeff(YonX):\t\t\t\t%f\n", r.Byx())
		fmt.Fprintf(writeAddr, "Covariance:\t\t\t\t\t%f\n", r.Covariance())
		fmt.Fprintf(writeAddr, "StdDev(Y):\t\t\t\t\t%f\n", r.SdY())
	case "XY":
		fmt.Fprintf(writeAddr, "Query(XonY for %f):\t\t\t%f\n", xquery, r.ModelXY(xquery))
		fmt.Fprintf(writeAddr, "Equation(XonY):\t\t\t\t%s\n", r.Equation("XonY"))
		fmt.Fprintf(writeAddr, "Confidence:\t\t\t\t\t%.2f%%\n", r.Conf()) // <-- not matching
		fmt.Fprintf(writeAddr, "Regression Coeff(XonY):\t\t\t\t%f\n", r.Bxy())
		fmt.Fprintf(writeAddr, "Covariance:\t\t\t\t\t%f\n", r.Covariance())
		fmt.Fprintf(writeAddr, "StdDev(X):\t\t\t\t\t%f\n", r.SdX())
	default:
		break
	}
	fmt.Fprintf(writeAddr, "*********************************************************\n")
}