2024-02-25 13:35:47 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "fmt"
|
2024-02-25 13:49:43 +00:00
|
|
|
import rand "math/rand/v2"
|
2024-02-25 13:35:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
import "math"
|
|
|
|
import "sync"
|
|
|
|
import rand "math/rand/v2"
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2024-02-25 13:49:43 +00:00
|
|
|
type src = *rand.Rand
|
|
|
|
|
|
|
|
func generateRandomMapping(r src) map[int]float64 {
|
|
|
|
current_probability := 0.0
|
|
|
|
mapping := make(map[int]float64)
|
|
|
|
for i := 0; i <= 1000; i++ {
|
|
|
|
if current_probability < 1.0 {
|
|
|
|
num_possible_steps := int((1-current_probability)/0.001) + 1
|
|
|
|
fmt.Println("num possible steps: %d", num_possible_steps)
|
|
|
|
step := float64(r.IntN(num_possible_steps)) * 0.001
|
|
|
|
current_probability += step
|
|
|
|
}
|
|
|
|
mapping[i] = current_probability
|
|
|
|
}
|
|
|
|
return mapping
|
|
|
|
}
|
|
|
|
|
2024-02-25 13:35:47 +00:00
|
|
|
func main() {
|
|
|
|
fmt.Println("Hello world")
|
|
|
|
|
2024-02-25 13:49:43 +00:00
|
|
|
var r = rand.New(rand.NewPCG(uint64(1), uint64(2)))
|
|
|
|
randomMapping := generateRandomMapping(r)
|
|
|
|
for i := 0; i <= 1000; i++ {
|
|
|
|
fmt.Printf("%d: %.4f\n", i, randomMapping[i])
|
|
|
|
}
|
|
|
|
|
2024-02-25 13:35:47 +00:00
|
|
|
}
|