I have a problem using it hist(). I created an array with 396 elements that contain all possible results
X + 0.5 Y + Z,
where 0 <= X,Z <=5and 0 <= Y <= 10. All I want to create is a frequency histogram, the height of the columns of which coincides with the probability that a certain value is taken under the assumption of an x,y,zindependent, uniformly distributed. I thought I would give a hist()try:
import pandas as pd
import matplotlib.pyplot as plt
def activity(x,y,z):
return 1 * x + 0.5 * y + 1 * z
rangex = np.arange(6)
rangey = np.arange(11)
rangez = np.arange(6)
rhs = 10
activities = [activity(x,y,z) for x in rangex for y in rangey for z in rangez]
activities = pd.Series(activities)
fig, axes = plt.subplots(1,1)
n, bins, patches = axes.hist(activities, bins=np.linspace(-0.25, 15.25, num=32), \
normed=True)
Here's the weird thing: n stacks up to 2 !!! With the choice, binsI made sure that each element falls into exactly 1 bit, and I know that exactly 31 bits are required, because my range of values is from 0 to 15 in increments of 0.5.
, . 100 . : 
, 1. , 11 0,1 . 1.
: ?
. , :
barposs, barheight = zip(*activities.value_counts(normalize=True).iteritems())
plt.bar(np.array(barposs) - 0.25, np.array(barheight), width=0.5, color='red')
.