Best way to store interquartile range

What is the best option to store an interquartile range with numpy in Python from these two options?

Option 1:
first_quarter = np.perceptile(my_array, 25)
third_quarter = np.perceptile(my_array, 75)
interquartile_range = third_quarter - first_quarter

Option 2:
interquartile_range = np.perceptile(my_array, 75) - np.perceptile(my_array, 25)

Do you have a link to the lesson or is this for a test or school assignment? If it’s for the latter, we cannot help with school tests or assignments.

It was a general question that came to me when doing the “Learn Stadistics with Numpy” in this site. What I wanted to know is, in terms of Python performance, if it’s better to use more variables that contain ‘simplier’ information, or to use fewer variables that store more complicated calculations.

I’m not sure about performance so, maybe someone else can chime in on that.
I guess how you store them would be based on if you want to use those variables for further analysis. If that makes sense? Like, if you wanted to analyze the first_quarter alone, or the third_quarter, etc.

1 Like