0

Friedman Test

Unsolved
Prob. and Stats

Difficulty: 2 | Problem written by Junaid Ahmed
Problem reported in interviews at

Amazon
Apple
Facebook
Google
Netflix

The Friedman test verifies that frequent measurements of the same individual have the same pattern. It's often used to check for consistency between measurements taken in various ways. If two measuring methods are used on the same group of individuals, the Friedman test can be used to see if they are reliable.

The equation for the Friedman test is:

\(Fr=\frac{12}{nk(k+1)}(d1^{2}+d2^{2}+d3^{2})-3n(k+1) \)

d1, d2, and d3 are the samples or data points

n is the number of independent blocks

k is the number of clusters or groups

As opposed to ANOVA, the Friedman test has the benefit of being more commonly applicable. The Friedman test is used to examine multiple samples that are related (i.e., dependent). Friedman named his system "the method of rankings" since it relies on swapping initial points with rank-ordered scores.

Write a Python function to implement the Friedman Test using the equation above.

Use different input values to check the validity of the program

Sample Input:
<class 'int'>
n: 12
<class 'int'>
k: 3
<class 'int'>
d1: 35
<class 'int'>
d2: 24
<class 'int'>
d3: 13

Expected Output:
<class 'float'>
23496.0

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.

Autem repudiandae corporis aut recusandae possimus natus cum assumenda, laudantium odit dolore eaque debitis nulla quaerat veritatis et? Officiis mollitia facilis quam accusantium a nobis qui hic, ea eius nam iusto aspernatur recusandae nemo saepe magni iure doloribus, velit at repellendus quisquam architecto quo est doloremque, maiores consequatur ea ipsum aspernatur deleniti doloremque voluptatum nobis? Non ducimus amet, laboriosam explicabo atque repellat veritatis voluptate.

Amet corrupti sapiente rem architecto exercitationem culpa et nisi voluptates sint. Aliquid quibusdam magni similique odio, accusamus earum maxime placeat iure suscipit voluptates optio velit soluta aspernatur, incidunt mollitia sed possimus recusandae amet. Id porro voluptatibus in, commodi beatae voluptate molestiae voluptates incidunt consequuntur est neque dolor molestias, pariatur harum vitae at architecto maxime nostrum voluptates perspiciatis sapiente, sed autem repellat harum ipsam magni nesciunt ipsa officiis, similique et nostrum cumque qui.

Earum sed ex esse nostrum fuga aliquid in, corrupti quo dolorum magnam dolorem officiis, illo distinctio numquam placeat impedit pariatur laborum aperiam maiores, quasi inventore qui praesentium quae quaerat? Adipisci exercitationem perferendis, porro qui amet beatae eligendi eaque? Iste iusto saepe numquam cum similique officiis harum nemo quia repellat expedita, veritatis ex perferendis modi numquam sapiente voluptatum vitae maxime, exercitationem debitis sed beatae voluptatem dolores eos delectus explicabo. Ipsum distinctio reprehenderit officia voluptates perspiciatis in error itaque ratione ea, praesentium ab perferendis fuga voluptatibus tempora architecto vitae repudiandae qui totam?

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)