Experiment: Weighted Decision Function in Aiken #1039
Replies: 2 comments 1 reply
-
Issues:
|
Beta Was this translation helpful? Give feedback.
-
Congratulations. You have all been blocked. |
Beta Was this translation helpful? Give feedback.
-
Create a new function that takes a list of choices and a list of probabilities, and returns a random decision based on the weights.
Here i wrote Some Code Plz See it
...
module WeightedDecision {
// Import the Random module for generating random numbers
import Random
pub fn weighted_choice(choices: List[String], probabilities: List[Float]) -> String {
let sum_probs = List.sum(probabilities)
}
}
...
Function Defination:
The function will accept two lists:
List)
.float
between0.0
and1.0
), with the sum of probabilities equal to 1.0.Code Implementation
...
module WeightedDecision {
// Import the Random module for generating random numbers
import Random
pub fn weighted_choice(choices: List[String], probabilities: List[Float]) -> String {
let sum_probs = List.sum(probabilities)
}
}
...
Beta Was this translation helpful? Give feedback.
All reactions