go-hep.org/x/hep@v0.38.1/hbook/rootcnv/testdata/gen-2d-data.go (about)

     1  // Copyright ©2017 The go-hep Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build ignore
     6  
     7  package main
     8  
     9  import (
    10  	"fmt"
    11  	"log"
    12  	"math/rand"
    13  	"os"
    14  
    15  	"gonum.org/v1/gonum/mat"
    16  	"gonum.org/v1/gonum/stat/distmv"
    17  )
    18  
    19  func main() {
    20  	const npoints = 10000
    21  
    22  	dist, ok := distmv.NewNormal(
    23  		[]float64{0, 1},
    24  		mat.NewSymDense(2, []float64{4, 0, 0, 2}),
    25  		rand.New(rand.NewSource(1234)),
    26  	)
    27  	if !ok {
    28  		log.Fatalf("error creating distmv.Normal")
    29  	}
    30  
    31  	w := os.Stdout
    32  
    33  	v := make([]float64, 2)
    34  	// Draw some random values from the standard
    35  	// normal distribution.
    36  	for i := 0; i < npoints; i++ {
    37  		v = dist.Rand(v)
    38  		fmt.Fprintf(w, "%g %g %g\n", v[0], v[1], 1.0)
    39  	}
    40  }