make iterator loop a bit more elegant
This commit is contained in:
parent
1fceb128bb
commit
3526ab4b31
23
probppl.go
23
probppl.go
|
@ -23,19 +23,9 @@ func generatePeopleKnownDistribution(r src) IntProbabilities {
|
|||
var probabilities IntProbabilities
|
||||
sum := 0.0
|
||||
|
||||
// Consider zero case separately
|
||||
/*p0 := r.Float64()
|
||||
mapping[0.0] = p0
|
||||
sum += p0
|
||||
*/
|
||||
|
||||
// Consider successive exponents of 1.5
|
||||
num := 16.0
|
||||
base := 2.0
|
||||
for i := 1; i < 8; i++ {
|
||||
num = num * base
|
||||
for i := 16; i <= 2048; i *= 2 {
|
||||
p := r.Float64()
|
||||
probabilities = append(probabilities, IntProbability{N: int64(num), p: p})
|
||||
probabilities = append(probabilities, IntProbability{N: int64(i), p: p})
|
||||
sum += p
|
||||
}
|
||||
|
||||
|
@ -147,21 +137,22 @@ func main() {
|
|||
|
||||
var distribs []IntProbabilitiesWeights
|
||||
|
||||
sum := int64(0)
|
||||
sum_weights := int64(0)
|
||||
for i := 0; i < 100; i++ {
|
||||
|
||||
people_known_distribution := generatePeopleKnownDistribution(r)
|
||||
// fmt.Println(people_known_distribution)
|
||||
result := getUnnormalizedBayesianUpdateForDistribution(people_known_distribution, r)
|
||||
fmt.Println(i)
|
||||
// fmt.Println(i)
|
||||
if result > 0 {
|
||||
fmt.Println(people_known_distribution)
|
||||
fmt.Println(result)
|
||||
distribs = append(distribs, IntProbabilitiesWeights{IntProb: people_known_distribution, w: result})
|
||||
}
|
||||
sum += result
|
||||
sum_weights += result
|
||||
// fmt.Println(result)
|
||||
}
|
||||
fmt.Println(sum)
|
||||
// fmt.Println(distribs)
|
||||
|
||||
// Now calculate the posterior
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user