A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/python/python_statistics_median_grouped_function.htm below:

Python statistics.median_grouped()Function

Python statistics.median_grouped()Function

The Python statistics.median_grouped() calculates the median of grouped data, as the 50th percentile.

This function considers data points as continuous data and calculates the 50% median by using a specified interval width (default value = 1).

The mathematical formula for Grouped Median is −

GMedian = L + interval * (N/2-CF)/F.
Syntax

Following is the basic syntax of the statistics.median_grouped() function −

statistics.median_grouped(data, interval)
Parameters

Here, the data values can be used as any sequence, list or iterator. When it comes to intervals, the default value is 1.

Return Value

This function returns the median of the grouped continuous data.

Example 1

In the below example, we are calculating the median of grouped continuous data using statistics.median_grouped() function −

import statistics
x = statistics.median_grouped([1, 3, 7, 9])
print(x)
Output

This produces the following result −

6.5
Example 2

The following example calculates the median of the grouped continuous data using statistics.median_grouped() function −

import statistics
x = statistics.median_grouped([2, 5, 7, 9], 5)
print(x)
Output

The output obtained is as follows −

4.5
Example 3

Now, we are calculating the median for the float values using statistics.median_grouped() function.

import statistics
x = statistics.median_grouped([3.2, 5.6, 0.7, 1.9], 2.5)
print(x)
Output

This result is produced as follows −

1.9500000000000002

python_modules.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4