ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

Python tutorial: Cumulative Distribution Functions

Автор: DataCamp

Загружено: 2016-11-09

Просмотров: 85355

Описание: Learn about empirical cumulative distribution functions: https://www.datacamp.com/courses/stat...

We saw in the last video the clarity of bee swarm plots. However, there is a limit to their efficacy. For example, imagine we wanted to plot the county-level voting data for all states east of the Mississippi River and all states west. We make the swarm plot as before, but using a DataFrame that contains all states, with each classified as being east or west of the Mississippi.

The bee swarm plot has a real problem. The edges have overlapping data points, which was necessary in order to fit all points onto the plot. We are now obfuscating data. So, using a bee swarm plot here is not the best option.

As an alternative, we can compute an empirical cumulative distribution function, or ECDF. Again, this is best explained by example. Here is a picture of an ECDF of the percentage of swing state votes that went to Obama. A x-value of an ECDF is the quantity you are measuring, in this case the percent of vote that sent to Obama. The y-value is the fraction of data points that have a value smaller than the corresponding x-value. For example, 20% of counties in swing states had 36% or less of its people vote for Obama. Similarly, 75% of counties in swing states had 50% or less of its people vote for Obama.

Let's look at how to make one of these from our data. The x-axis is the sorted data. We need to generate it using the NumPy function sort, so we need to import Numpy, which we do using the alias np as is commonly done. The we can use np.sort() to generate our x-data. The y-axis is evenly spaced data points with a maximum of one, which we can generate using the np.arange() function and then dividing by the total number of data points. Once we specify the x and y values, we plot the points.

By default, plt.plot() plots lines connecting the data points. To plot our ECDF, we just want points. To achieve this we pass the string '.' and the string 'none' to the keywords arguments marker and linestyle, respectively.

As you remember from my forceful reminder in an earlier video, we label the axes. Finally, we use the plt.margins() function to make sure none of the data points run over the side of the plot area. Choosing a value of 0.02 gives a 2% buffer all around the plot.

The result is the beautiful ECDF I just showed you. We can also easily plot multiple ECDFs on the same plot. For example, here are the ECDFs for the three swing states. We see that Ohio and Pennsylvania were similar, with Pennsylvania having slightly more Democratic counties. Florida, on the other hand, had a greater fraction of heavily Republican counties.

In my workflow, I almost always plot the ECDF first. It shows all the data and gives a complete picture of how the data are distributed. But don't take my word for how great ECDFs are. You can see for yourself in the exercises!

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
Python tutorial: Cumulative Distribution Functions

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

ECDF: альтернативный график гистограмм

ECDF: альтернативный график гистограмм

L08.7 Cumulative Distribution Functions

L08.7 Cumulative Distribution Functions

Normal Distribution in Python: A Beginner's Guide with Scipy & Numpy

Normal Distribution in Python: A Beginner's Guide with Scipy & Numpy

Python Tutorial: Learn Python For Data Science

Python Tutorial: Learn Python For Data Science

Метод анализа главных компонентов (PCA) объяснен простыми словами.

Метод анализа главных компонентов (PCA) объяснен простыми словами.

Seaborn distplot | Интерпретация Seaborn distplot и как построить график распределения в Seaborn

Seaborn distplot | Интерпретация Seaborn distplot и как построить график распределения в Seaborn

Normal Distribution (PDF, CDF, PPF) in 3 Minutes

Normal Distribution (PDF, CDF, PPF) in 3 Minutes

What is a Cumulative Distribution Function (CDF) of a Random Variable?

What is a Cumulative Distribution Function (CDF) of a Random Variable?

Basic Sound Processing in Python | SciPy 2015 | Allen Downey

Basic Sound Processing in Python | SciPy 2015 | Allen Downey

Calculating a Cumulative Distribution Function (CDF)

Calculating a Cumulative Distribution Function (CDF)

Lecture 05: Summarizing and Describing Data

Lecture 05: Summarizing and Describing Data

What is a violin plot and how to make a Seaborn violinplot in Python

What is a violin plot and how to make a Seaborn violinplot in Python

Kernel Density Estimation : Data Science Concepts

Kernel Density Estimation : Data Science Concepts

⚡️ Зеленский пошёл против армии || Путин срочно созвал Совбез РФ

⚡️ Зеленский пошёл против армии || Путин срочно созвал Совбез РФ

Отключения интернета - это подготовка. Что задумали власти?

Отключения интернета - это подготовка. Что задумали власти?

Как Быстро ВЫУЧИТЬ Python в 2026 году

Как Быстро ВЫУЧИТЬ Python в 2026 году

Диктатор готовит второй фронт? / Военные сборы или мобилизация?

Диктатор готовит второй фронт? / Военные сборы или мобилизация?

⚡НАКИ: ШУТКИ КОНЧИЛИСЬ! Россияне в ЛОВУШКЕ: невменяемый Путин ВЕДЁТ К БЛОКАДЕ. Кремль ДИКО НАПУГАН

⚡НАКИ: ШУТКИ КОНЧИЛИСЬ! Россияне в ЛОВУШКЕ: невменяемый Путин ВЕДЁТ К БЛОКАДЕ. Кремль ДИКО НАПУГАН

Detecting Anomalies Using Statistical Distances | SciPy 2018 | Charles Masson

Detecting Anomalies Using Statistical Distances | SciPy 2018 | Charles Masson

Путин готовит новую мобилизацию? Военный обзор Юрия Фёдорова

Путин готовит новую мобилизацию? Военный обзор Юрия Фёдорова

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]