Skip to content
This repository has been archived by the owner on Dec 22, 2018. It is now read-only.

add normal quantile #157

Merged
merged 1 commit into from
Feb 19, 2017
Merged

add normal quantile #157

merged 1 commit into from
Feb 19, 2017

Conversation

btracey
Copy link
Member

@btracey btracey commented Feb 9, 2017

No description provided.

distmv/normal.go Outdated
// Quantile returns the multi-dimensional inverse cumulative distribution function.
// len(x) must equal len(p), and if x is non-nil, len(x) must also equal len(p).
// If x is nil, a new slice will be allocated and returned, otherwise the quantile
// will be stored in-place into x. All of the values of p must be between 0 and 1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inclusive

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

distmv/normal.go Outdated
@@ -246,6 +246,29 @@ func (n *Normal) Prob(x []float64) float64 {
return math.Exp(n.LogProb(x))
}

// Quantile returns the multi-dimensional inverse cumulative distribution function.
// len(x) must equal len(p), and if x is non-nil, len(x) must also equal len(p).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this.

Also, at the moment there is no explicit length check for x when x != nil; the panic is potentially a runtime bounds check if len(x) < len(p), otherwise a panic in TransformNormal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the explicit check for size.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand "len(x) must equal len(p), and if x is non-nil, len(x) must also equal len(p)." the first "len(x)" is presumably supposed to be something else, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, the comment was non-sensical. Fixed.

distmv/normal.go Outdated
func (n *Normal) Quantile(x, p []float64) []float64 {
dim := n.Dim()
if len(p) != dim {
panic(badSizeMismatch)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

badInputLength?

(I'm not sure that badSizeMismatch is a good label anyway - what does it mean? A really bad size mismatch or a size mismatch is not actually a size mismatch).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is badSizeMismatch supposed to be used for? I think we should bring these constants together - having them spread around in separate files the way they are leads to this kind of problem.

@btracey
Copy link
Member Author

btracey commented Feb 18, 2017

ping

@btracey
Copy link
Member Author

btracey commented Feb 19, 2017

Thanks

@btracey btracey merged commit d98eda0 into master Feb 19, 2017
@btracey btracey deleted the addnormquant branch February 19, 2017 07:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants