algorithm

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: GPL-3.0, GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

* @author PalletOne core developers <dev@pallet.one> * @date 2018

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Selected

func Selected(expectedNum uint, weight, total uint64, vrf []byte) int

subUsers return the selected amount of sub-users determined from the mathematics protocol. expectedNum 期望数量 weight 设置固定数值,即返回概率值*weight,返回值落在0 -- expectedNum/Total*weight之间的数值

Types

type ApproxBinomial

type ApproxBinomial struct {
	N uint64
	// contains filtered or unexported fields
}

ApproxBinomial is an approximate distribution function of Binomial distribution. It can only be used when τ >>> W (when p = τ / W ).

func NewApproxBinomial

func NewApproxBinomial(expected int64, n uint64) *ApproxBinomial

func (*ApproxBinomial) CDF

func (ab *ApproxBinomial) CDF(k int64) *big.Rat

func (*ApproxBinomial) Prob

func (ab *ApproxBinomial) Prob(k int64) *big.Rat

type Binomial

type Binomial interface {
	CDF(int64) *big.Rat
	Prob(int64) *big.Rat
}

type PrivateKey

type PrivateKey struct {
	// contains filtered or unexported fields
}

func (*PrivateKey) PublicKey

func (priv *PrivateKey) PublicKey() *PublicKey

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

type RegularBinomial

type RegularBinomial struct {
	N *big.Int
	// contains filtered or unexported fields
}

Binomial implements the binomial distribution function. It's too slow!!!

func NewBinomial

func NewBinomial(n, pn, pd int64) *RegularBinomial

func (*RegularBinomial) CDF

func (b *RegularBinomial) CDF(j int64) *big.Rat

二项式累计分布函数

func (*RegularBinomial) Exp

func (b *RegularBinomial) Exp(x *big.Int, y float64) *big.Int

exp computes x**y with a optimize way.

func (*RegularBinomial) Prob

func (b *RegularBinomial) Prob(k int64) *big.Rat

func (*RegularBinomial) Probability

func (b *RegularBinomial) Probability() *big.Rat

Jump to

Keyboard shortcuts

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