Back to Community
Lecture 11 Binomial Random Variable class definition

Lecture 11 is great, very interesting, however I have a question regarding the definition of the BinomialRandomVariable class- specifically: why does it include the DiscreteRandomVariable class in its parameters?

I ask because it seemed odd to me to include it; and I may be mistaken, but removing the (DiscreteRandomVariable ) parameter from the BinomialRandomVariable class definition appears to have no impact on the function or outcome of the code?

I'm probably making an error that I just can't see but would love to have this cleared up - thank you fellow Quantopians!!

class BinomialRandomVariable(DiscreteRandomVariable):  
    def __init__(self, numberOfTrials = 10, probabilityOfSuccess = 0.5):  
        self.variableType = "Binomial"  
        self.numberOfTrials = numberOfTrials  
        self.probabilityOfSuccess = probabilityOfSuccess  
        return  
    def draw(self, numberOfSamples):  
        samples = np.random.binomial(self.numberOfTrials, self.probabilityOfSuccess, numberOfSamples)  
        return samples  

vs.

class BinomialRandomVariable:  
    def __init__(self, numberOfTrials = 10, probabilityOfSuccess = 0.5):  
        self.variableType = "Binomial"  
        self.numberOfTrials = numberOfTrials  
        self.probabilityOfSuccess = probabilityOfSuccess  
        return  
    def draw(self, numberOfSamples):  
        samples = np.random.binomial(self.numberOfTrials, self.probabilityOfSuccess, numberOfSamples)  
        return samples