Documentation
¶
Index ¶
- func AlignPeaksToSamplePositions(sampleCount int, peaks []int) []int
- func TestCountBinary(bitWidth int)
- func TestCountBinary0(bitWidth int)
- func TestCountDecimal()
- func TestMergeOfTriples()
- func TestMultipass()
- func TestMultipass0()
- func TestPeakDetectTriple()
- type Number
- type Peaks
- type PrimaryPeaks
- func (p *PrimaryPeaks[T]) GetPeakCount() int
- func (p *PrimaryPeaks[_]) GetPeaks() []int
- func (p *PrimaryPeaks[T]) GetSampleCount() int
- func (p *PrimaryPeaks[T]) GetSamples() []T
- func (p *PrimaryPeaks[T]) Inflate() []T
- func (p *PrimaryPeaks[T]) InflateInto(peaks []T, from Peaks[T])
- func (p *PrimaryPeaks[T]) InflateWithCount(samples int, from Peaks[T]) []T
- type SecondaryPeaks
- func CreateSecondaryPeaksWith[T Number](p PrimaryPeaks[T], primaryPeaks []int, originalPeaks []int) SecondaryPeaks[T]
- func DetectPeaksInPrimary[T Number](p PrimaryPeaks[T]) SecondaryPeaks[T]
- func DetectPeaksInSecondary[T Number](p SecondaryPeaks[T]) SecondaryPeaks[T]
- func IteratePeakDetect[T Number](iterations uint, samples []T) (SecondaryPeaks[T], bool)
- func IteratePeakDetectToCompletion[T Number](samples []T) SecondaryPeaks[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestCountBinary ¶
func TestCountBinary(bitWidth int)
func TestCountBinary0 ¶
func TestCountBinary0(bitWidth int)
func TestCountDecimal ¶
func TestCountDecimal()
func TestMergeOfTriples ¶
func TestMergeOfTriples()
func TestMultipass ¶
func TestMultipass()
func TestMultipass0 ¶
func TestMultipass0()
func TestPeakDetectTriple ¶
func TestPeakDetectTriple()
Exhaustive test of all possible peaks in a cluster of 3 samples, wherein each sample can only be one of 3 possible unique values.
We have a total of three samples, each of which can be an arbitrary integer.
Let us look at the problem by first limiting each sample to a set of the following possible unique values: {0, 1, 2}
Because we have a total of 3 samples, and each of which can only take on the above possible values, the resulting space of possibilities is 3^3=27.
In other words, there are 27 ways in which we can express 3 samples, such that we can encode all their possible differences. For example, the first sample being greater than the second or less than it, or equal to it. The same of the second and third samples, and the third and first.
Suppose for example, that our alphabet was limited only to the symbols: {0, 1}
In this case, we would not be able to express all possible differences in the cluster of 3 samples, because we could never express a full ramp. In order to be able to express a full ramp, we must have as many unique symbols in our alphabet, as there are samples.
Hence, since we have 3 samples, our alphabet needs 3 unique symbols: {0, 1, 2}
We can now express a full ramp:
|2| |1|1| |0|1|2| |0|0|0|
Next, we need to enumerate all possible differences between every two samples, out of the 3 total. This is the standard 'N choose K' problem, wherein we have to choose 2 values out of 3, without regard for order of the 2 chosen items.
Out of a set of 3 samples, 'a', 'b' and 'c', we have the following 3 possibilities:
a b c Let us encode our difference relations as such:
-----
a b The choices 'ab', 'bc' and 'cd', allow
b c for the following possibilities:
a c
(A > b) Ab (B > c) Bc (C > a) Ca
(a < B) aB (b < C) bC (c < A) aC
(a == b) ab (b == c) bc (c == a) ac
We can now see what the logic would look like, when trying to express the above state space of 27 possible differences between two 2 samples, out of 3 total:
if a < b { // aB
if b < c { // bC
if c < a { // cA
<leaf>
} else if c > a { // Ca
<leaf>
} else { // c == a, ca
<leaf>
}
} else if b > c { Bc
<branch>
} else { // b == c, bc
<branch>
}
} else if a > b { // Ab
<branch>
} else { // a == b, ab
<branch>
}
Below, we feed all 27 possible clusters of 3 samples, wherein the alphabet is limited to 3 unique symbols, leading to 3^3=27 total possibilities.
Types ¶
type Number ¶
type Number interface {
constraints.Integer | constraints.Float
}
type Peaks ¶
type Peaks[T Number] interface { GetSampleCount() int GetPeakCount() int GetSamples() []T GetPeaks() []int }
func PrimaryValuesOnly ¶
func PrimaryValuesOnly[T Number](p *SecondaryPeaks[T]) Peaks[T]
type PrimaryPeaks ¶
type PrimaryPeaks[T Number] struct { // contains filtered or unexported fields }
func CreatePeaks ¶
func CreatePeaks[T Number](a, b, c T, peaks []int) PrimaryPeaks[T]
func CreatePeaksWith ¶
func CreatePeaksWith[T Number](samples []T, peaks []int) PrimaryPeaks[T]
func DetectPeaks ¶
func DetectPeaks[T Number](samples []T) PrimaryPeaks[T]
func (*PrimaryPeaks[T]) GetPeakCount ¶
func (p *PrimaryPeaks[T]) GetPeakCount() int
func (*PrimaryPeaks[_]) GetPeaks ¶
func (p *PrimaryPeaks[_]) GetPeaks() []int
func (*PrimaryPeaks[T]) GetSampleCount ¶
func (p *PrimaryPeaks[T]) GetSampleCount() int
func (*PrimaryPeaks[T]) GetSamples ¶
func (p *PrimaryPeaks[T]) GetSamples() []T
func (*PrimaryPeaks[T]) Inflate ¶
func (p *PrimaryPeaks[T]) Inflate() []T
Inflate returns an array wherein all samples that were originally not peaks, are set to zero, and wherein all peaks are set to their original peak values
func (*PrimaryPeaks[T]) InflateInto ¶
func (p *PrimaryPeaks[T]) InflateInto(peaks []T, from Peaks[T])
func (*PrimaryPeaks[T]) InflateWithCount ¶
func (p *PrimaryPeaks[T]) InflateWithCount(samples int, from Peaks[T]) []T
type SecondaryPeaks ¶
type SecondaryPeaks[T Number] struct { PrimaryPeaks[T] // contains filtered or unexported fields }
func CreateSecondaryPeaksWith ¶
func CreateSecondaryPeaksWith[T Number](p PrimaryPeaks[T], primaryPeaks []int, originalPeaks []int) SecondaryPeaks[T]
func DetectPeaksInPrimary ¶
func DetectPeaksInPrimary[T Number](p PrimaryPeaks[T]) SecondaryPeaks[T]
func DetectPeaksInSecondary ¶
func DetectPeaksInSecondary[T Number](p SecondaryPeaks[T]) SecondaryPeaks[T]
func IteratePeakDetect ¶
func IteratePeakDetect[T Number](iterations uint, samples []T) (SecondaryPeaks[T], bool)
func IteratePeakDetectToCompletion ¶
func IteratePeakDetectToCompletion[T Number](samples []T) SecondaryPeaks[T]
func (*SecondaryPeaks[_]) GetPrimaryPeaks ¶
func (p *SecondaryPeaks[_]) GetPrimaryPeaks() []int
func (*SecondaryPeaks[T]) GetPrimarySamples ¶
func (p *SecondaryPeaks[T]) GetPrimarySamples() []T