简体   繁体   中英

Python Standard Deviation - Efficiency issues with assigning variables

I'm currently working on a program to find standard deviation, z score, etc from some numbers, but my program is extremely inefficient. The way I'm doing it right now by assigning each number its own variable, adding, dividing, assigning that a new variable, so it becomes an infinitely large wall of code. What would be a more efficient way of calculating this than assigning each number its own variable? Also, is there a way to make a list of these numbers based on the number of numbers the user inputs and append these numbers to the list AND THEN do the math?

If you want speed, use numpy . With just using the numpy array things are going to go MUCH faster.

Also scipy has what you want, see this .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM