Skip to content Skip to sidebar Skip to footer

Bivariate Cdf/ccdf Distribution Python

I am trying to plot a bivariate ccdf of the dataset that has x and y values both. Univariate I can plot very well, below is the input and the code is for univeriate dataset. Inpu

Solution 1:

Bivariate distributions the way you're trying to describe are oftentimes continuous, for instance the size of a house (input, x) and it's price (output, y.) In your case there is no meaningful relationship (I think) in the number of the keyword, as it's probably just an ID assigned to the keyword right?

In your case to me it seems as though you have categories (keywords). each category appears to have two numbers a tweetcricscore and a keyword number. \

Your code here:

cdf0 = np.arange(len(X0))/float(len(X0))

To me suggests that your x range is just their labels and not a meaningful value.

A better source for categorical plots can be found here.

To create a bivariate distribution, assuming that's still what you want having read that, you'd do the following using your data as an example using your data from above:

import numpy as np
import seaborn as sns

col_1 = np.array([34, 23, 24, 456, 653, 789, 625, 86, 3, 87, 98])
col_3 = np.array([51, 46, 12, 46, 1, 178, 46, 23, 1, 8, 56])

sns.jointplot(x=col_3, y=col_1)

Which produces the very nonsensical figure here:

enter image description here

You'll have to add the x and y labels manually; this is because you're passing numpyarrays instead of pandasDataframes which can be thought of like dictionaries where each key in the dictionary is the title of a column, and the value the numpy array.

Using random numbers to show how it might look with a more random, continuous, related dataset.

This is the example taken from the docs.

import numpy as np
import seaborn as sns
import pandas as pd

mean, cov = [0, 1], [(1, .5), (.5, 1)]
data = np.random.multivariate_normal(mean, cov, 200)
df = pd.DataFrame(data, columns=["x", "y"])
sns.jointplot(x="x", y="y", data=df);

Which gives this:

enter image description here

The bar graphs on top of the chart can be thought of as uni variate charts (what you probably have produced) because they just describe the distribution of one or the other variable (x, or y, col_3, or col_1)

Post a Comment for "Bivariate Cdf/ccdf Distribution Python"