Select to view content in your preferred language

How to write python expression and code block for Geometric Mean

2889
10
Jump to solution
10-09-2018 12:48 AM
ParthBansal
Emerging Contributor

I am building a model to calculate geometric mean for each shape file in model builder. How to do write Expression and Code Block which would:

Take in shapefile "City_1" and use all the values in Field "Area" and calculate n√a*b*c*d. ..... where n are number of values in field "Area" and a,b,c,d are all the value in field "Area"

0 Kudos
10 Replies
DanPatterson_Retired
MVP Emeritus

Since 'area' was mentioned... consider 3 land parcels of 10, 100, and 1000 hectares.

what is the mean-ish thing?

import scipy.stats as st

areas = np.array([10, 100, 1000])

st.gmean(areas)  # --- floating point 'issues' but 100
99.99999999999996


np.mean(areas)   # ---- hmmmmm ;)
370.0