github.com/GuanceCloud/cliutils@v1.1.21/pipeline/ptinput/funcs/md/sample.en.md (about) 1 ### `sample()` {#fn-sample} 2 3 Function prototype: `fn sample(p)` 4 5 Function description: Choose to collect/discard data with probability p. 6 7 Function parameters: 8 9 - `p`: the probability that the sample function returns true, the value range is [0, 1] 10 11 Example: 12 13 ```python 14 # process script 15 if !sample(0.3) { # sample(0.3) indicates that the sampling rate is 30%, that is, it returns true with a 30% probability, and 70% of the data will be discarded here 16 drop() # mark the data to be discarded 17 exit() # Exit the follow-up processing process 18 } 19 ```