Interview Query

Truncated Distribution

5
Have you seen this question before?

Given a percentile_threshold, sample size NN, and mean and standard deviation mm and sdsd of the normal distribution, write a function truncated_dist to simulate a normal distribution truncated at percentile_threshold.

Example:

Input:

m = 2
sd = 1
n = 6
percentile_threshold = 0.75

Output:

def truncated_dist(m,sd,n, percentile_threshold): ->

 [2, 1.1, 2.2, 3, 1.5, 1.3]

All values in the output sample are in the lower 75% = percentile_threshold of the distribution.

Next question: Liked Pages
.....
Python 3.9.6
Loading editor
Use Shift + Enter to run code