Blue Week Special Offer | Brighten your week!
days
hours
minutes
seconds

No plots were detected

Screen Link: https://app.dataquest.io/m/99/chi-squared-tests/4/generating-a-distribution

Code:

chi_squared_values =

import numpy as np
import matplotlib.pyplot as plt

chi_squared_values =

for i in range(1000):
random_values = np.random.random_sample(32561, )
random_values[random_values < .5] = 0
random_values[random_values >= .5] = 1

females = (random_values == 1).sum()
males = (random_values == 0).sum()

female_diff = (females-16280.5)**2/16280.5
male_diff = (males-16280.5)**2/16280.5
chi_squared = female_diff + male_diff
chi_squared_values.append(chi_squared)

plt.hist(chi_squared_values)

What I expected to happen:
print a plot

What actually happened:
Got an error

No plots were detected, but 1 plot was expected

It started to work now!

Hi @risto.launis. Thank you for reporting this! I am glad to see it is working for you now. I checked this screen and it is working for me as well. Best,
-Casey

Hi both, I have exactly the same problem now. I copied and pasted the solution code instead of my own code (which generated the right values) but it still does not produce a plot.

@ramin0vali:

Please refresh the screen and it should work after a while. If it still doesn’t please follow up.

It’s working now. Thanks. I don’t know why this happens?

sometimes this is a glitch @ramin0vali

I added plt.show() and only then it worked.

same here - the following code does not produce a plot:

chi_squared_values = []
from numpy.random import random
import matplotlib.pyplot as plt

for i in range(1000):
    sequence = random((32561,))
    male_count = len(sequence[sequence < 0.5])
    female_count = len(sequence[sequence >= 0.5])
    male_diff = (male_count - 16280.5) ** 2 / 16280.5
    female_diff = (female_count - 16280.5) ** 2 / 16280.5
    chi_squared = male_diff + female_diff
    chi_squared_values.append(chi_squared)

plt.hist(chi_squared_values)

I have tried several versions, but only the one from solution works.

@ybabych: I was able to get a plot using your code. Maybe you could try again later or login to DQ using another browser (or clear your browser cache)… hard to say if this is on the client or server side…

If those still don’t work, I would advise you to send in a ticket at the bottom of this page.

cc @nityesh