Has research involving the generalization of the arithmetic mean been done for the following? Purpose
Problem: How do we create a new measure that yields the same (arithmetic) mean for functions where the mean is well-defined and has a unique value but calculates a new arithmetic mean for functions where it's not well-defined or does not have a unique value.
Specifically, I wish to generalize the mean to find a new average for functions defined on $A\subseteq \mathbb{R}$ such when using the Lebesgue Measure ($\lambda$) and integral, the mean:
$$\frac{1}{\lambda(A)}\int_{A}f(x)$$
is undefined if $\lambda(A)=0$; the mean using the counting measure
$$\frac{1}{\mu(A)}\sum\limits_{x\in A}f(x)$$
is undefined if $\mu(A)=+\infty$
and the mean using the Haar Measure and Integral is well-defined but not unique without axiom of choice.
From this, it follows from functions where the mean is undefined, that its domains are almost continuous nowhere, with infinite points and a zero-measure domain.
Main Question
What Research Has Been Done On This Problem?
(Below is my attempt to solve my purpose)


First Attempt To Generalize The Mean
Defining Measure $\mathcal{P}$
If $S\subseteq A$:

*

*$\ell$ is the length of an interval

*$\left(J_{k} \right)_{k=1}^{m}$ for $m\in\mathbb{N}$, are a sequence of open intervals where $\;\ell(J_1)=...=\ell(J_m)=g\in\mathbb{R}^{+}$ and the infimum is taken over all $J_k$ of:

\begin{align}
\mathcal{M}(g,S)= g\cdot\inf\left\{m\in\mathbb{N}: {S^{\prime}\text{ is countable}, \left(S\setminus S^{\prime}\right)\subseteq\bigcup\limits_{k=1}^{m}J_{k}}\right\} 
\end{align}
and
$$\mathcal{N}(S,A)=\lim\limits_{g\to 0}\frac{\mathcal{M}\left(g,S\right)}{\mathcal{M}\left(g,A\right)}$$
then if
\begin{align}
& \mathcal{O}(g,S)=\\ & \begin{cases} \small{g\cdot\inf\left\{m\in\mathbb{N}: {S_{j}\subseteq S, \;  \mathcal{N}(S_{j},A)=0,\;\bigcup\limits_{j=1}^{\infty}{S}_{j}=S^{\prime\prime},\;\left(S\setminus S^{\prime\prime}\right)\subseteq\bigcup\limits_{k=1}^{m}J_{k}}\right\}} & A \text{ is uncountable}\\
g\cdot\inf\left\{m\in\mathbb{N}: S\subseteq\bigcup\limits_{k=1}^{m}J_{k}\right\} & A \text{ is countable}
\end{cases}
\end{align}
then the outer measure is
$$\mathcal{P}^{*}(S,A)=\lim\limits_{g\to 0}\frac{\mathcal{O}(g,S)}{\mathcal{O}(g,A)}$$
And the inner measure is $\mathcal{P}_{*}(S,A)=1-\mathcal{P}^{*}(A\setminus S,A)$, meaning measure $\mathcal{P}(S,A)$ exists when $\mathcal{P}^{*}(S,A)=\mathcal{P}_{*}(S,A)$.
When $\mathcal{P}(S,A)$ is defined, the average of $f:A\to B$ is defined as follows:
First, split $[a,b]=[\min(A),\max(A)]$ into sub-intervals using partitions $x_i$
$$a= x_0 \le \dots \le x_i \le \dots \le x_r =b$$
Here, if $1\le i \le r$, then $[x_{i-1},x_i]$ are sub-intervals of $[a,b]$.
For every $i$, choose a $v_i\in A\cap[x_{i-1}, x_{i}]$ and define $A_i=A\cap[x_{i-1},x_i]$. Then define set $P$, such that $i \in P\subseteq\left\{1,...,r\in\mathbb{N}\right\}$ when $A\cap[x_{i-1},x_i]\neq\emptyset$. This gives
\begin{align}
& \lim_{r\to\infty}\sum_{i\in P} f(v_i) \times \mathcal{P}(A_i,A) 
\end{align}
(This may look tedious but we can use shortcuts to simplify the sum. If I write it out my post will be too long.)
Example Where $\mathcal{P}$ Is Undefined
Consider the following:
Therefore, $f:\left\{\frac{1}{s}:s\in\mathbb{N}\right\}\to\left\{0,1 \right\}$
\begin{align*}
 f(x)=\begin{cases} 
1 & x\in \left\{\frac{1}{2s+1}:s\in\mathbb{N}\right\} \\
0 & x\in \left\{\frac{1}{2s}:s\in\mathbb{N}\right\}
\end{cases}
\end{align*}
Suppose $S_1=\left\{\frac{1}{2s+1}:s\in\mathbb{N}\right\}$ and $S_2\in\left\{\frac{1}{2s}:s\in\mathbb{N}\right\}$
Using $\mathcal{P}^{*}$, I approximated (and wish to prove using box-dimensions) that $\mathcal{P}^{*}(S_1,S_1\cup S_2)\ge 1/\sqrt{2}$ and $\mathcal{P}^{*}(S_2,S_1\cup S_2)\ge 1/\sqrt{2}$. Hence, $\mathcal{P}_{*}(S_1,S_1\cup S_2)=1-\mathcal{P}^{*}(S_2,S_1\cup S_2)\le 1-1/\sqrt{2}$ but $1/\sqrt{2}\neq 1-1/\sqrt{2}$. Hence for this case my measure is undefined.
Now we need a measure that gives the same value as $\mathcal{P}(S,A)$ when defined but a different value when $\mathcal{P}(S,A)$ is undefined.
Last Request
I believe I found the final answer to my problem (the answer is below my post); however, I wish someone would check. If someday my answers make sense could you please mention this to me?
Currently, I'm in undergrad but if I do not let go of my "research", I could struggle in my studies. Hopefully, someone can verify my ideas so I may be at peace.
 A: My 2 cents: I suppose what you would like to have is a partially ordered family $\{\mu_i\}_{i\in I}$ of measures such that for $i<j$, we have $\mu_i(A)<\infty\implies \mu_j(A)=0$. Then for every $A\subseteq \Bbb R$, there exists at most one $i\in I$ with $0<\mu_i(A)<\infty$, and if such $i$ exists, we define the mean of $f\colon A\to\Bbb R$ to be $\frac1{\mu_i(A)}\int_Af\,\mathrm d\mu_i$ (assuming integrability). For conveninece, we may also wish each $\mu_i$ to be translation invariant. The Lebesgue measure and the counting measure would already be two nice-to-have members of such a family, and we wish to have a family as big as possible.
Using Zorn's lemma, we can infer the existence of a maximal such family. Unfortunately, such a maximal family is probably highly non-constructive.
A: Defining First Measure
If $S\subseteq A$:

*

*$\ell$ is the length of an interval

*$\left(I_{n}\right)_{j=1}^{n}$ and $\left(J_{k} \right)_{k=1}^{m}$, for $m\in\mathbb{N}$, are a sequence of open intervals where $\left(I_1\right)=\left(I_2\right)=...=\left(I_{n}\right)=g\in\mathbb{R}^{+}$, $\;\ell(J_1)=...=\ell(J_m)=g\in\mathbb{R}^{+}$ and the infimum in the equations below are taken over all possible $I_j$ and $J_k$
\begin{align}
\mathcal{M}(g,S)=\begin{cases} g\cdot\inf\left\{m\in\mathbb{N}: {S^{\prime}\text{ is countable}, \; \left(S\setminus S^{\prime}\right)\subseteq\bigcup\limits_{k=1}^{n}I_{n}}\right\} & A \text{ is uncountable}\\
 g\cdot\inf\left\{m\in\mathbb{N}: {S\subseteq\bigcup\limits_{k=1}^{n}I_{n}}\right\} & A \text{ is countable} \end{cases}
\end{align}
and
$$\mathcal{N}(S,A)=\lim\limits_{g\to 0}\frac{\mathcal{M}\left(g,S\right)}{\mathcal{M}\left(g,A\right)}$$
then if
\begin{align}
\mathcal{O}(g,S)=  \small{g\cdot\inf\left\{m\in\mathbb{N}: {S_{j}\subseteq S, \;  \mathcal{N}(S_{j},A)=0,\;\bigcup\limits_{j=1}^{\infty}{S}_{j}=S^{\prime},\;\left(S\setminus S^{\prime}\right)\subseteq\bigcup\limits_{k=1}^{m}J_{k}}\right\}}
\end{align}
(I added $\mathcal{O}(g,S)$ so when $A$ is an intervals of finite lengths, $\mathcal{O}(g,S)$ gives the Lebesgue Measure of $S$ divided by the Lebesgue Measure of $A$.)
therefore the outer measure is
$$\mathcal{P}^{*}(S,A)=\lim\limits_{g\to 0}\frac{\mathcal{O}(g,S)}{\mathcal{O}(g,A)}$$
And the inner measure is $\mathcal{P}_{*}(S,A)=1-\mathcal{P}^{*}(A\setminus S,A)$, which means measure $\mathcal{P}(S,A)$ exists when $\mathcal{P}^{*}(S,A)=\mathcal{P}_{*}(S,A)$.
Now note $S$ and $A$, when $\mathcal{P}(S,A)$ is undefined, can also have a measure when $S$ and $A$ have a algebraic notation written in terms of subsets of $\mathbb{R}$.
Defining Algebraic Form
For arbitrary set $A$, if

*

*$p_{1,1},...,p_{w,q_{w}}\subseteq\mathbb{R}$ and $z_{1,1},...,z_{w,v_w}\subseteq\mathbb{R}$
(For example the subsets can be $\mathbb{Z}$, the Cantor Set, or finite length intervals and:)

*$w=[1,...,l\in\mathbb{N}]$

*$T_{1,1},...,T_{l,w}:p_{1,1,1} \times...\times p_{l,w,q_{l,w}}\times z_{1,1},...,z_{w,v_w}\to\mathbb{R}$
then the algebraic form of $A$, or $\alpha$ is:
\begin{align}
& \alpha=\bigcup_{w=1}^{l}\bigcap\limits_{u_{w,1}\in z_{w,1}}...\bigcap\limits_{u_{w,v_{w}}\in z_{w,v_{w}}}\bigcup\limits_{s_{w,1}\in p_{w,1}}...\bigcup\limits_{s_{w,q_{w}}\in p_{w,q_{w}}}\left\{T_{l,w}\left(s_{w,1},...,s_{w,q_{w}},u_{w,1},...,u_{w,v_{w}}\right)\right\}
\end{align}
To illustrate, when set $A$ has an algebraic form $\alpha_1=\bigcup\limits_{m\in\mathbb{Z}}\bigcup\limits_{n\in\mathbb{Z}}\left\{\frac{m}{8n+4}\right\}$ where

*

*$l\in \left(k_1=\left\{1\right\}\right)$

*$w\in \left(k_2=\left\{1\right\}\right)$

*$s_{1,1,1}=m$ and $p_{1,1,1}=\mathbb{Z}$

*$s_{1,1,2}=n$ and $p_{1,1,2}=\mathbb{Z}$
other algebraic forms must be equivelant to $\alpha_{1}$. For example, another algebraic form of $A$ is $\alpha_2=\bigcup\limits_{m_1\in\mathbb{Z}}\bigcup\limits_{m_2\in\mathbb{Z}}\left\{\frac{2m_1+1}{8m_2+4}\right\}\cup\bigcup\limits_{m_3\in\mathbb{Z}}\bigcup\limits_{m_4\in\mathbb{Z}}\left\{\frac{m_{3}}{12m_4+6}\right\}$ where

*

*$w\in k_1=\left\{1\right\}$

*$l\in k_2=\left\{1,2\right\}$

*$s_{1,1,1}=m_1$ and $p_{1,1,1}=\mathbb{Z}$

*$s_{1,1,2}=m_2$ and $p_{1,1,2}=\mathbb{Z}$

*$s_{1,2,1}=m_3$ and $p_{1,2,1}=\mathbb{Z}$

*$s_{1,2,2}=m_4$ and $p_{1,2,2}=\mathbb{Z}$
Since $\alpha_1=\alpha_2$, $\alpha_2$ is an algebraic form of $A$.
Moreover, note we can define the set of all algebraic forms of $A$ as $\mathcal{A}(A)$ where $\alpha\in\mathcal{A}(A)$. For example:
$$\mathcal{A}(\mathbb{Q})=\left\{\left\{\frac{m}{n}:m,n\in\mathbb{Z}\right\},\left\{\frac{m}{2n}:m,n\in\mathbb{Z}\right\},...,\left\{\frac{m}{n^2}:m,n\in\mathbb{Z}\right\},...\right\}$$
And an $\alpha\in\mathcal{A}\left(\mathbb{Q}\right)$ is $\alpha=\left\{\frac{m}{n}:m,n\in\mathbb{Z}\right\}$
Therefore, we can now define a "Folner-like" Sequence inorder to define a measure
Defining New Measure
Going back to $\alpha$. If

*

*$\Phi_{1,w}=\left\{1,...,q_{w}\in\mathbb{N}\right\}$

*$\Phi_{2,w}=\left\{1,...,v_{w}\in\mathbb{N}\right\}$

*$i_{1,w},r_{w}\in\Phi_{{1,w}}$

*$i_{2,w}\in\Phi_{2,w}$

*$t_{w}\in\Phi_{2,w}\setminus\{r_{w}\}$
then $\alpha$ becomes
\begin{alignat}{2}
&\mathcal{F}(w,\alpha,\psi,r_{l,w},\epsilon,\omega)= \\ &\bigcup\limits_{i_{1,w}\in\Phi_{1,w}}\bigcap\limits_{\large{u_{i_{2,w}}\in z_{i_{2,w}}}}\bigcup\limits_{\large{s_{w,i_{w}}\in p_{i_{w}}}}&&\left\{T_{w}\left(s_{w,1},...,s_{w,q_{w}},u_{w,1},...,u_{w,v_{w}}\right):\left|s_{w,t_{w}}\right|\le \omega, |u_{w,i_{2,w}}|\le\eta\right. \\ &  &&\left. \left|T_{w}\left(s_{w,1},...,s_{w,q_{w}},u_{w,1},...,u_{w,v_{w}}\right)-\psi \right|\le\epsilon \right\}
\end{alignat}
Note if all $p_{w}$ are subsets of $\mathbb{Z}$ and $\omega\to\infty$ for every $\eta$ when $\eta\to\infty$, then each $s_{r_{w}}$ would give different Folner Sequences. However, this forces us to choose a particular $r_{w}$.
Also note we add $\left|T_{w}\left(s_{w,1},...,s_{w,q_{w}},u_{w,1},...,u_{w,v_{w}}\right)-\psi \right|\le\epsilon$ so when $A$ is dense in an interval and $S\subseteq A$ is dense almost nowhere, the density of $S$ using Folner-esque sequences is always zero.
To avoid choosing between different $r_{w}$, take the intersection of all of them and take the Folner Sequences of the $l$ and $w$'s which helps obtain a measure that matches $\mathcal{P}$ when $\mathcal{P}(S,A)$ is defined.
\begin{align}
\alpha_{\mathcal{F}}\left(\alpha,\psi,\epsilon,\omega,\eta\right)=\bigcup\limits_{w=1}^{l}\bigcap\limits_{r_{w}\in\Phi_{w}}\mathcal{F}\left(w,\alpha,\psi,r_{w},\epsilon,\omega,\eta\right)
\end{align}
(Note we take $k_1$ less than $\eta$ so when $A=\mathbb{Q}$ one can derive a unique Folner Sequence which gives a unique measure.)
However, there are multiple algebraic forms of $\alpha$ in $A$ which prevent us from obtaining such a measure. Therefore we add additional criteria:
If $\alpha_1,\alpha_2\in\mathcal{A}(A)$ we solve
$$\beta=\inf\left\{\lim\limits_{\epsilon\to 0}\lim\limits_{\eta\to\infty}\lim\limits_{\omega\to\infty}\mathcal{P}\left(\alpha_{\mathcal{F}}(\alpha_1,\psi,\epsilon,\omega,\eta),\alpha_{\mathcal{F}}(\alpha_1\cup\alpha_2,\psi,\epsilon,\omega,\eta)\right)\right\}$$
and take the set of all $\alpha_1$ that gives $\beta$.
$$\mathcal{A}_{\beta}(A)= \left\{\alpha_1:\left(\forall\alpha_{2}\right)\left(\lim\limits_{\epsilon\to 0}\lim\limits_{\eta\to\infty}\lim\limits_{\omega\to\infty}\mathcal{P}\left(\alpha_{\mathcal{F}}(\alpha_1,\psi,\epsilon,\omega,\eta),\alpha_{\mathcal{F}}(\alpha_1\cup\alpha_2,\psi,\epsilon,\omega,\eta)\right)=\beta\right)\right\}$$
For example, when $A=\mathbb{Q}$, the Folner Sequence
$$\lim\limits_{\epsilon\to 0}\lim\limits_{\eta\to\infty}\lim\limits_{\omega\to\infty}\bigcap_{k\in\mathbb{N},|k|\le\eta}\left(\bigcup\limits_{n\in\mathbb{Z},|n|\le\omega}\bigcup_{m\in\mathbb{Z}}\left\{\frac{m}{n^{k}}:\left|\frac{m}{n^k}-\psi\right|\le\epsilon\right\}\cup\bigcup\limits_{n\in\mathbb{Z}}\bigcup_{m\in\mathbb{Z},|m|\le\omega}\left\{\frac{m}{n^{k}}:\left|\frac{m}{n^k}-\psi\right|\le\epsilon\right\}\right)$$
Should be in $\mathcal{A}_{\beta}(A)$
(We can picture the triple-limit as follows: For every $\epsilon>0$ and $\eta>0$, take $\omega$ as $\omega\to\infty$ then for every $\epsilon>0$ take $\eta$ as $\eta\to\infty$. As $\epsilon$ is evaluated for smaller values, the limit should converge.
Then take the union of all $\alpha$ in $\mathcal{A}_{\beta}(A)$ to get:
$A_{\mathcal{F}}\left(\psi,\epsilon,\omega\right)=\bigcup\limits_{\alpha\in\mathcal{A}_{\beta}(A)}\alpha_{\mathcal{F}}(\alpha,\psi,\epsilon,\omega)$
(Presumably), we are not only dealing with countable sets. Hence instead of taking the density of $S\subseteq A$ using Folner Sequences:
\begin{align}
    \lim\limits_{\epsilon\to 0}\lim\limits_{\omega\to\infty}\frac{\left|S\cap A_{\mathcal{F}}\left(\psi,\epsilon,\omega\right)\right|}{\left|A_{\mathcal{F}}\left(\psi,\epsilon,\omega\right)\right|}
\end{align}
We take
\begin{align}
    d(S,\psi)=\lim\limits_{\epsilon\to 0}\lim\limits_{\omega\to\infty}\mathcal{P}\left(S\cap A_{\mathcal{F}}\left(\psi,\epsilon,\omega\right),A_{\mathcal{F}}\left(\psi,\epsilon,\omega\right)\right)
\end{align}
Now, even if $d(S,\psi)$ exists, it only takes the density over $[\psi-\epsilon,\psi+\epsilon]$. Therefore, we broaden the density to all $A$ by taking the weighted average of $d(S,\psi)$ using $\mathcal{P}$. In formal terms:
Divide $[0,1]$ ($0\le d(S,\psi)\le 1$) into partitions $0=c_1\le \cdot\cdot\cdot\le c_i \le \cdot\cdot\cdot\le c_u=1$ where if $x_i\in[c_{i-1},c_i]$ and $C_i=[c_{i-1},c_i]$, then our final outer measure is
\begin{align}
& \mathcal{U}^{*}(S,A)= \lim\limits_{u\to\infty}\sum\limits_{i=1}^{u}x_i\cdot\mathcal{P}^{*}\left(\left\{\psi:d\left(S,\psi\right)=C_i\right\},A\right) 
\end{align}
And our final inner measure is
\begin{align}
& \mathcal{U}_{*}(S,A)= 1-\lim\limits_{u\to\infty}\sum\limits_{c=1}^{u}x_i\cdot\mathcal{P}^{*}\left(\left\{\psi:d\left(A\setminus S,\psi\right)=C_i\right\},A\right)
\end{align}
Therefore, $\mathcal{U}(S,A)$ exists when:
$$\mathcal{U}^{*}(S,A)=\mathcal{U}_{*}(S,A) $$
Generalizing the Measure
We can generalize our measure to $\mu$:
\begin{equation}
\mu(S,A)=\begin{cases}
\mathcal{P}(S,A) & \mathcal{P}^{*}(S,A)=\mathcal{P}_{*}(S,A) \\
\mathcal{U}(S,A) & \mathcal{P}^{*}(S,A)\neq\mathcal{P}_{*}(S,A), \; \mathcal{U}^{*}(S,A)=\mathcal{U}_{*}(S,A)
\end{cases}
\end{equation}
Defining The Average
To define the average, first split $[a,b]=[\min(A),\max(A)]$ into sub-intervals using partitions $x_i$
$$a= x_0 \le \dots \le x_i \le \dots \le x_r =b$$
Here, if $1\le i \le r$, then $[x_{i-1},x_i]$ are sub-intervals of $[a,b]$.
For every $i$, choose a $v_i\in A\cap[x_{i-1}, x_{i}]$ and define $A_i=A\cap[x_{i-1},x_i]$. Next we define set $P$, such that $i \in P\subseteq\left\{1,...,r\in\mathbb{N}\right\}$ when $A\cap[x_{i-1},x_i]\neq\emptyset$. This gives
\begin{align}
& \lim_{r\to\infty}\sum_{i\in P} f(v_i) \times \mu(A_i,A) 
\end{align}
(This may look tedious but we can use shortcuts to simplify the sum. If I write it out the post will be too long.)
