Table of Contents

				
					# Dataset
runners = [4, 3, 6, 8, 10, 11, 5]
				
			

Example 1 Manual Calc

				
					n = len(runners)
				
			
				
					# Calculate the sum of reciprocals
reciprocal_sum = sum(1/x for x in runners)
				
			
				
					# Calculate harmonic mean
harmonic_mean_manual = n / reciprocal_sum
				
			
				
					harmonic_mean_manual
				
			

Example 2 statistics

				
					import statistics as stats
				
			
				
					# Calculate harmonic mean
data = runners
harmonic_mean_stats = stats.harmonic_mean(runners)
				
			
				
					print(harmonic_mean_stats)
				
			
				
					df.loc[idx]
				
			
				
					df.loc[idx]
				
			

Example 3 scipy

				
					from scipy.stats import hmean
harmonic_mean_scipy = hmean(data)
				
			
				
					print(harmonic_mean_scipy)
				
			

Free Community

Join 1,000+ AI Automation Builders

Weekly tutorials, live calls & direct access to Ryan & Matt.

Join Free →

Keep Learning

python quantiles statistics

In Python, a quantile is a statistical term used to describe a point or value below which a certain proportion of the...

python variance and standard deviation

https://youtu.be/p4H2b2x_nWc#population and sample variance/std deviationVariance measures how far each data point in the set is from the mean andthus from every other...

Python Z-Score

We are going to be looking at Python Z-score. Z-score tells us how far a data poin is from the mean. https://youtu.be/QjG1ljFNF9U...

Spearman Rank Correlation

Spearman Rank Correlation [Simply explained] https://youtu.be/TNQTd9gR1c0 Example 2 Fast wth scipy