numcat { mae.earth/pkg/numcat }

Documentation

Number Catalogue for number sequences; useful in simulation programming.

Install with


go get mae.earth/pkg/numcat

Basic usage

Raw go file

package main 

import (
	"mae.earth/pkg/numcat/catalogue"
	"mae.earth/pkg/numcat/random"
	"fmt"
	"os"
)

const (
	TOTAL int = 100
)

func main() {

	/* read the catalogue */
	reader := catalogue.New()

	/* create a random tool */
	tool,err := random.New(reader)
	if err != nil {
		fmt.Fprintf(os.Stderr,"error creating random tool from catalogue -- %v\n",err)
		os.Exit(1)
	}

	for i := 0; i < TOTAL; i++ {
		
		n,err := tool.Normal()
		if err != nil {
			fmt.Fprintf(os.Stderr,"error requesting normal from random tool -- %v\n",err)
			os.Exit(2)
		}

		u,err := tool.Uniform()
		if err != nil {
			fmt.Fprintf(os.Stderr,"error requesting uniform from random tool -- %v\n",err)
			os.Exit(2)
		}

		fmt.Fprintf(os.Stdout,"%05d/%05d\t%f\t%f\n", i + 1, TOTAL, n, u)
	}
}


00001/00100	-0.078140	0.357677
00002/00100	0.012876	0.144433
00003/00100	0.270997	0.288809
00004/00100	0.212139	0.456235
00005/00100	0.757810	0.715882
00006/00100	0.190266	0.571945
00007/00100	-0.221779	0.071629
00008/00100	0.327695	0.422839
00009/00100	-0.169783	0.611308
00010/00100	-0.679592	0.165216
00011/00100	0.033169	0.881417
00012/00100	-0.322973	0.789067
00013/00100	-0.362204	0.304797
00014/00100	-0.613396	0.346822
00015/00100	0.271960	0.771775
00016/00100	0.416829	0.538232
00017/00100	0.032263	0.368219
00018/00100	-0.296458	0.140708
00019/00100	0.782081	0.461420
00020/00100	-0.050895	0.172742
00021/00100	0.860952	0.114923
00022/00100	0.556600	0.023170
00023/00100	-0.238320	0.878986
00024/00100	-0.247741	0.999671
00025/00100	0.061314	0.860669
00026/00100	0.228598	0.984700
00027/00100	-0.772409	0.901070
00028/00100	0.336322	0.720682
00029/00100	0.780903	0.045912
00030/00100	0.320465	0.857465
00031/00100	0.722179	0.838170
00032/00100	0.192340	0.125901
00033/00100	0.305989	0.737264
00034/00100	0.571564	0.160587
00035/00100	0.565517	0.488464
00036/00100	-0.569645	0.986929
00037/00100	-0.292753	0.109286
00038/00100	-0.172987	0.782748
00039/00100	-0.770068	0.652130
00040/00100	0.035638	0.642306
00041/00100	0.989683	0.611452
00042/00100	0.290677	0.410388
00043/00100	-0.295220	0.070531
00044/00100	-0.224381	0.249315
00045/00100	0.115874	0.024163
00046/00100	-0.868367	0.976002
00047/00100	-0.224573	0.889852
00048/00100	-0.049124	0.138390
00049/00100	-0.568490	0.442159
00050/00100	-0.276516	0.087035
00051/00100	-0.166417	0.746437
00052/00100	0.481050	0.923196
00053/00100	0.028761	0.441832
00054/00100	-0.295618	0.176432
00055/00100	-0.212448	0.784750
00056/00100	0.001614	0.494230
00057/00100	0.166344	0.637381
00058/00100	-0.030755	0.777042
00059/00100	0.139035	0.019468
00060/00100	-0.465876	0.359579
00061/00100	0.053798	0.713762
00062/00100	-0.111808	0.172901
00063/00100	0.497526	0.922691
00064/00100	0.513731	0.897857
00065/00100	-0.733792	0.521559
00066/00100	0.021274	0.276450
00067/00100	0.436431	0.960747
00068/00100	0.213413	0.639901
00069/00100	0.405509	0.431392
00070/00100	-0.196341	0.372263
00071/00100	-0.630700	0.854143
00072/00100	-0.091979	0.182440
00073/00100	-0.319861	0.842142
00074/00100	0.279584	0.966259
00075/00100	0.207008	0.326424
00076/00100	-0.141398	0.406690
00077/00100	0.617391	0.853414
00078/00100	-0.069719	0.247053
00079/00100	-0.165242	0.850253
00080/00100	0.272085	0.033626
00081/00100	-0.219435	0.080829
00082/00100	-0.061462	0.413233
00083/00100	-0.307446	0.262747
00084/00100	-0.671475	0.081201
00085/00100	0.338653	0.288745
00086/00100	0.592849	0.351058
00087/00100	0.000976	0.001927
00088/00100	-0.195209	0.915665
00089/00100	-0.547033	0.377069
00090/00100	0.429115	0.582609
00091/00100	0.348458	0.741401
00092/00100	-0.208713	0.475212
00093/00100	0.270715	0.635365
00094/00100	0.098332	0.651349
00095/00100	-0.446165	0.245344
00096/00100	0.744177	0.467693
00097/00100	-0.419235	0.385940
00098/00100	-0.003925	0.594902
00099/00100	-0.417739	0.142345
00100/00100	0.277668	0.388027