pi

package
v0.0.0-...-dfef690 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Pi estimates the value of Pi using Monte Carlo method.

We throw darts into a circle. We can estimate the area of the circle as area of the image * hits / miss. "Throwing a dart" means getting random x / y directions.

Circle is represented by a GIMP-made 1024x1024 png image. Circle is black and the background is white. There is some gradient on the border. We consider 50%+ gray to be black.

Index

Constants

View Source
const Scale = 1_000_000_000

scale is the scale factor we use to avoid floating point arithmetics

Variables

This section is empty.

Functions

func New

func New(args *Args) (montecarlo.Experiment, error)

Returns new experiment based on the args

Types

type Args

type Args struct {
	// How many sample histories do we want to run during the experiment
	Histories int

	// How many darts do we want to throw for each sample
	Rounds int

	// Which image to use as the target
	Image string
}

Args represents the parameters of the Pi estimation simulation

func (*Args) String

func (a *Args) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL