I’m going to assume that you want to compute the expression given by the following pseudocode:
ms = 0 for i = 1 ... N ms = ms + y[i]^2 ms = ms / N rms = sqrt(ms)
i.e. the square root of the mean of the squared values of elements of y
.
In numpy, you can simply square y
, take its mean and then its square root as follows:
rms = np.sqrt(np.mean(y**2))
So, for example:
>>> y = np.array([0, 0, 1, 1, 0, 1, 0, 1, 1, 1]) # Six 1's >>> y.size 10 >>> np.mean(y**2) 0.59999999999999998 >>> np.sqrt(np.mean(y**2)) 0.7745966692414834
Do clarify your question if you mean to ask something else.
Related Posts:
- Import Error: No module named numpy
- How to normalize a NumPy array to within a certain range?
- Sorting arrays in NumPy by column
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- ValueError: setting an array element with a sequence
- Numpy ValueError: setting an array element with a sequence. This message may appear without the existing of a sequence?
- numpy: Invalid value encountered in true_divide
- How do I create an empty array/matrix in NumPy?
- numpy matrix vector multiplication
- How do I read CSV data into a record array in NumPy?
- How do I read CSV data into a record array in NumPy?
- Factorial in numpy and scipy
- Convert pandas dataframe to NumPy array
- size of NumPy array
- ValueError: all the input arrays must have same number of dimensions
- TypeError: cannot unpack non-iterable int objec
- ValueError: setting an array element with a sequence
- Using Numpy Vectorize on Functions that Return Vectors
- How to raise a numpy array to a power? (corresponding to repeated matrix multiplications, not elementwise)
- ‘End of statement expected’ in pycharm
- Is there a NumPy function to return the first index of something in an array?
- Numpy/Python Array Value error
- initialize a numpy array
- Overflow Error in Python’s numpy.exp function
- load csv into 2D matrix with numpy for plotting
- How to access the ith column of a NumPy multidimensional array?
- Dump a NumPy array into a csv file
- Python: find position of element in array
- numpy with python: convert 3d array to 2d
- Python: slicing a multi-dimensional array
- How to remove specific elements in a numpy array
- Add single element to array in numpy
- Overflow Error in Python’s numpy.exp function
- How to normalize a 2-dimensional numpy array in python less verbose?
- Make list of arrays in python
- Understanding NumPy’s einsum
- For loop and ‘numpy.float64’ object is not iterable error
- Moving average or running mean
- How to fix “TypeError: len() of unsized object”
- TypeError: Invalid dimensions for image data when plotting array with imshow()
- Numpy.dot TypeError: Cannot cast array data from dtype(‘float64’) to dtype(‘S32’) according to the rule ‘safe’
- How to get the unit vector from a numpy array
- Moving average or running mean
- How to start from second index for for-loop
- Official abbreviation for: import scipy as sp/sc
- numpy-equivalent of list.pop?
- Using numpy to build an array of all combinations of two arrays
- Efficiently sorting a numpy array in descending order?
- How to plot an array in python?
- TypeError: only integer arrays with one element can be converted to an index 3
- How to create a numpy array of all True or all False?
- How to create a numpy array of lists?
- Removing nan values from an array
- How to fix ‘RuntimeWarning: divide by zero encountered in double_scalars’
- Python 3: Multiply a vector by a matrix without NumPy
- IndexError: index 2 is out of bounds for axis 0 with size 2
- ImportError in importing from sklearn: cannot import name check_build
- How to add a new row to an empty numpy array
- What are the differences between numpy arrays and matrices? Which one should I use?
- Compute a confidence interval from sample data
- Numpy – add row to array
- ImportError: cannot import name NUMPY_MKL
- built-in range or numpy.arange: which is more efficient?
- Is there any numpy group by function?
- Mean Squared Error in Numpy?
- Numpy Resize/Rescale Image
- numpy array concatenation error: 0-d arrays can’t be concatenated
- Convert a 1D array to a 2D array in numpy
- inverting image in Python with OpenCV
- How to print the full NumPy array, without truncation?
- How to install NumPy for Python 3.6
- TypeError: zip argument #2 must support iteration
- numpy/scipy/ipython:Failed to interpret file as a pickle
- SyntaxError: unexpected EOF while parsing
- How to use filter, map, and reduce in Python 3
- How to declare an array in Python?
- Use Gif Logo For Loading Screen In Kivy
- Praw & Discord.py: The bot keep sending the same meme. I want the bot to send different meme whenever it is asked
- How can I make a time delay in Python? [duplicate]
- Python – TypeError: ‘int’ object is not iterable
- How to open a file using the open with statement
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
- TypeError: list indices must be integers or slices, not str
- ImportError: DLL load failed: The specified module could not be found
- ImportError: DLL load failed: The specified module could not be found
- How to install pip with Python 3?
- What is the difference between rw+ and r+
- Python – TypeError: ‘int’ object is not iterable
- Python3 – ModuleNotFoundError: No module named ‘numpy’
- Python: ‘ModuleNotFoundError’ when trying to import module from imported package
- Relative imports – ModuleNotFoundError: No module named x
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python3
- How to uninstall a package installed with pip install –user
- Relative imports in Python 3
- numpy max vs amax vs maximum
- TypeError: only size-1 arrays can be converted to Python scalars (matplotlib)
- What exactly does numpy.exp() do? [closed]
- Best way to convert string to bytes in Python 3?
- Best way to convert string to bytes in Python 3?