Simplifying a formula for the Normalised Gibbs Entropy

excel_lisa

New Member
Joined
Apr 17, 2021
Messages
5
Office Version
  1. 365
Platform
  1. MacOS
Hi,

I want to write a formula that computes the normalised Gibbs entropy, which is computed as follows:
1619785515230.png

The values that I want to test this for are located in column Z, AD, AH, AL, AP, AT, AX, ..... CL etc. so 3 columns are skipped every time.
I want to test for values 0 - 10.
I already wrote a code to test this formula for value '1', which is as follows:
=(COUNTIFS(Z3;1;AD3;1;AH3;1;AL3;1;AP3;1;AT3;1;AX3;1;BB3;1;BF3;1;BJ3;1;BN3;1;BR3;1;BV3;1;BZ3;1;CD3;1;CH3;1;CL3;1)/U3)*(IFERROR(LN(COUNTIFS(Z3;1;AD3;1;AH3;1;AL3;1;AP3;1;AT3;1;AX3;1;BB3;1;BF3;1;BJ3;1;BN3;1;BR3;1;BV3;1;BZ3;1;CD3;1;CH3;1;CL3;1)/U3);0))/LN(U3)
The only way I can think of computing the normalised Gibbs entropy is repeating this formula for each value from 0 to 10 as a criterion in the COUNTIFS function, and then compute the Sum of all outcomes and multiply by -1.
My Dataframe is 23000 rows so I think my Excel will also crash if I try to execute such a large formula.
Is there a smarter way to do this so that I won't have to write this formula 10 more times and so that the formula is more simple and compact?

Thank you in advance!
Lisa

P.S. If you know a way to do this in Python, please let me know as well
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
My thermo is super rusty (30 years since I thought about Gibbs for maybe a week).
In your system there are as many as 17 states, and the probabilities of any state is in Z, AD, AH, ...CL?
And U3 has the N value which is some function of particles and Boltzmann's constant???
Wouldn't all the pi add up to 1? Not all be 1.
If you have 23,000 rows, this formula will run slow.
MrExcelPlayground2.xlsx
ABCDEFGHIJKLMNOPQRST
1Np1p2p3p4p5p6p7p8p9p10p11p12p13p14p15p16p17PG
230.0150.0140.0890.0880.0490.0320.0580.0230.0790.0550.0990.0250.0820.0410.0270.0900.13312.4250313
340.0370.0310.0760.0970.0270.0020.0920.0860.0030.0820.0870.0790.0600.0660.0400.0880.04811.91814862
450.3000.0420.0360.0200.0860.0730.0130.0060.0650.0420.0920.0300.0070.0180.0850.0490.03611.49140582
560.0110.2000.0670.0530.0370.0720.0150.0210.0940.0730.0650.0930.0700.0260.0670.0300.00811.43855603
Sheet17
Cell Formulas
RangeFormula
S2:S5S2=SUM(B2:R2)
T2:T5T2=-SUM((B2:R2)*LN((B2:R2))/LN(A2))
 
Upvote 0
Hi,

Thank you for your answer!
I actually use the Normalised Gibbs Entropy for something else, namely to measure the diversity of educational backgrounds in a team.
Columns Z, AD, AH, ...CL all have a number from 0 to 10, which represents an educational field. Column U has the team size (number of team members).
I need to compute the proportion pi of team members that have a certain educational background, and then multiply by ln(pi) and divide by ln(N), in which N is the team size.
I did did using the above mentioned countif formula. However, I will need to repeat this 10 times for each educational background to compute the normalised Gibbs Entropy per team.
Therefore I was wondering whether there is an easier way to do this.

Hope this is a clear explanation for you, thanks!
 
Upvote 0
I don't think I'll understand what you are trying to calculate, but you can use arrays of 1 to 10 and sum all the countifs up.

Excel Formula:
=SUM(COUNTIFS(Z3,{1,2,3,4,5,6,7,8,9,10},AD3,{1,2,3,4,5,6,7,8,9,10},....))
 
Upvote 0

Forum statistics

Threads
1,214,914
Messages
6,122,211
Members
449,074
Latest member
cancansova

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top