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
- TypeError: only size-1 arrays can be converted to Python scalars (matplotlib)
- Best way to convert string to bytes in Python 3?
- PermissionError: [Errno 13] Permission denied
- What is setup.py?
- TypeError: ‘type’ object is not subscriptable when indexing in to a dictionary
- Error: all the input array dimensions except for the concatenation axis must match exactly
- Invalid character in identifier
- How to find all occurrences of an element in a list
- TypeError: ‘numpy.float64’ object is not callable
- ‘str’ object has no attribute ‘decode’. Python 3 error?
- How to find all the indexes of a recurring item in a list?
- ‘DataFrame’ object has no attribute ‘sort’
- How do you use subprocess.check_output() in Python?
- filename.whl is not a supported wheel on this platform
- How can I install Python’s pip3 on my Mac?
- Purpose of `numpy.log1p( )`?
- How to take column-slices of dataframe in pandas
- Get ZeroDivisionError: float division in python
- “for line in…” results in UnicodeDecodeError: ‘utf-8’ codec can’t decode byte
- pythonw.exe or python.exe?
- How to create an integer array in Python?
- Python Error – TypeError: input expected at most 1 arguments, got 3 [duplicate]
- A general tree implementation?
- What is the correct format to write float value to file in Python
- How is Python’s List Implemented?
- “E: Unable to locate package python3-pip”
- Shuffle an array with python, randomize array item order with python