Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to change this define function?

Crubal Chenxi LiCrubal Chenxi Li Posts: 1

The following Error Message shows up in the last 'Plot' procedure: In Z(Q), 'numpy.float64' object is not iterable.

I would like Z(Q) returns value that sum each i in the range (0, len(p)), which is a function with variable Q. And finally the plot is Q(X Axis) and Z(Q)(Y Axis) for each Q it can be plotted.

How can I modify Z(Q)? Thank you!

Code:

import numpy as np
import scipy.stats as stats
from scipy.stats import poisson, norm

cs = 100
co = 300
mu = 4.7

G = poisson(mu)
p = G.pmf(np.arange(3*mu))

Define Z(Q) function

def Z(Q):
for i in range(len(p)):
return sum(p[i]csmax((Q-i), 0) + p[i]comax((i-Q), 0))

Plot Q and (Q)

import pylab as pl

x = []
y = []

for Q in range(0, 12):
x.append(Q)
y.append(Z(Q))

pl.plot(x, y, '-o')
pl.show()

Sign In or Register to comment.