mirror of
				https://github.com/fjosw/pyerrors.git
				synced 2025-11-04 09:35:45 +01:00 
			
		
		
		
	feat: correlation parameter added to covariance again, tests extended.
This commit is contained in:
		
					parent
					
						
							
								8d93ff95f2
							
						
					
				
			
			
				commit
				
					
						da0c43fe9a
					
				
			
		
					 2 changed files with 26 additions and 15 deletions
				
			
		| 
						 | 
				
			
			@ -1332,7 +1332,7 @@ def correlate(obs_a, obs_b):
 | 
			
		|||
    return o
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def covariance(obs, visualize=False, **kwargs):
 | 
			
		||||
def covariance(obs, visualize=False, correlation=False, **kwargs):
 | 
			
		||||
    """Calculates the covariance matrix of a set of observables.
 | 
			
		||||
 | 
			
		||||
    covariance([obs, obs])[0,1] is equal to obs.dvalue ** 2
 | 
			
		||||
| 
						 | 
				
			
			@ -1343,7 +1343,9 @@ def covariance(obs, visualize=False, **kwargs):
 | 
			
		|||
    obs : list or numpy.ndarray
 | 
			
		||||
        List or one dimensional array of Obs
 | 
			
		||||
    visualize : bool
 | 
			
		||||
        Plots the corresponding normalized correlation matrix.
 | 
			
		||||
        If True plots the corresponding normalized correlation matrix (default False).
 | 
			
		||||
    correlation : bool
 | 
			
		||||
        If True the correlation instead of the covariance is returned (default False).
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    length = len(obs)
 | 
			
		||||
| 
						 | 
				
			
			@ -1368,7 +1370,10 @@ def covariance(obs, visualize=False, **kwargs):
 | 
			
		|||
        plt.colorbar()
 | 
			
		||||
        plt.draw()
 | 
			
		||||
 | 
			
		||||
    return cov
 | 
			
		||||
    if correlation is True:
 | 
			
		||||
        return corr
 | 
			
		||||
    else:
 | 
			
		||||
        return cov
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def _covariance_element(obs1, obs2):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue