1

Standard Deviation and Variance

Unsolved
Prob. and Stats

Difficulty: 1 | Problem written by Mr. Umair
Problem reported in interviews at

Amazon
Facebook
Netflix

The Standard Deviation is a measure of how spread out numbers are. In statistical analysis, standard deviation plays an important role. It can be computed using below given formula.

                                                        \(\sigma =\sqrt{\frac{1}{N}\sum_{i=1}^{N}(X_i-\mu)^2}\)

 

Variance can be defined as the average of the squared differences from the Mean. It can be calculated using below given formula.

                                                        \(\sigma^2 =\frac{1}{N}\sum_{i=1}^{N}(X_i-\mu)^2\)

 

Input:

Our function will take 1D NumPy Array and computes standard deviation and variance using array given in input.

Output:

This function will return a list having length 2 which contains Standard Deviation and Variance in their corresponding place.

Sample Input:
<class 'list'>
arr: [array([8, 8, 3, 7, 7, 0, 4])]

Expected Output:
<class 'list'>
[2.813959371941744, 7.918367346938775]

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Placeat culpa a quis sint accusamus et officia itaque possimus, voluptatibus soluta atque laborum aspernatur doloremque vitae harum placeat id, aperiam officia mollitia, ea neque vel voluptatum tempora quos, sed a atque culpa voluptate iste consequuntur ipsum provident excepturi ducimus.

Facere molestiae maiores asperiores illum, voluptatibus eveniet ipsum laudantium et maiores qui placeat voluptas, quas porro minima adipisci a dolorem odio doloribus distinctio suscipit, et vitae eos quaerat doloribus reprehenderit accusamus necessitatibus nisi ad, eveniet labore animi voluptates deserunt voluptate veritatis officia mollitia? Cupiditate quasi fugit neque veritatis ea est quas vitae odit corrupti aut, iure velit aliquid libero odio quae eaque molestias ducimus non, ad aliquid magnam delectus perspiciatis fugit, voluptate expedita quia reprehenderit laudantium dolores a illum est saepe nam, sint ab optio doloribus? Unde illo cumque similique odit atque commodi sequi, voluptatibus accusantium alias minus error aliquid totam eum officia necessitatibus quam, dicta sapiente aut vero facere soluta laborum a modi. Odit voluptatem corrupti maxime hic deleniti quis, repudiandae dolores sunt, atque beatae rerum nihil voluptates molestiae porro deleniti explicabo placeat?

Velit laudantium facere ab consequatur quos fuga aspernatur atque ratione, optio totam vitae fuga, facilis officia voluptatem ullam unde libero labore? Tempore debitis voluptatum quis voluptate vitae dolorum nesciunt error libero impedit nihil, placeat nihil qui vel labore omnis ducimus tempora error velit culpa? Atque voluptatibus fugiat odit omnis quis, labore quod atque ipsa ad recusandae aperiam pariatur tempore architecto nihil, totam eos id quae, fuga pariatur odit dignissimos neque inventore expedita sapiente mollitia quod?

This is a premium feature.
To access this and other such features, click on upgrade below.

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)