<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def reduced_chi_squared(self, p=None):
 """ Returns the reduced chi squared for all massaged data sets. p=None means use the fit results. """

        
        if len(self._set_xdata)==0 or len(self._set_ydata)==0: return None
        if p is None: p = self.results[0]
        
        chi2 = self.chi_squared(p)
        dof  = self.degrees_of_freedom()
        if not _s.fun.is_a_number(chi2) or not _s.fun.is_a_number(dof):
            return None
        
        return _n.divide(self.chi_squared(p), self.degrees_of_freedom())