# function with a given average value, how to create?

I want to create a function f(x) defined on the interval [0..1], which has all of the following properties on the interval:

1. It is continuous and differentiable throughout the interval, and can be expressed in a closed form without integrals, or through the use of piecewise functions.
2. $f'(x)$ is never negative for any value of $x \in [0..1]$
3. $f(0)$ is 0 and $f(1)$ is 1. and $f''(x)$ cannot change sign more than once in the interval.
4. If one were to select an $x$ randomly from a perfectly uniform distribution on $[0..1]$, the limit on the average $f(x)$ over an infinite number of tries approaches some particular value $c$.

Given some real value for $c \in (0..1)$, what is the simplest way to generate an $f(x)$ that satisfies the criteria?

The first three criteria are fairly easy to achieve... consider the rational function: $$g(x) = \frac{xk}{2kx-k-x+1}$$ satisfies the first 3 properties, guaranteeing intersection with the point $\left(\frac{1}{2},k \right)$, and even satisfies the 4th property for special case where $k=c=\frac{1}{2}$.

I do not know, however, how to satisfy the 4th property in general. I am thinking that it may simply be some kind of modification to the above function, but don't know for sure.

Do I need to find a value of $k$ for the above function $g(x)$ such the closed integral of $g(x)$ for $x=0..1$ = $c$? This might be possible for me to calculate, I haven't tried yet, but if it doesn't yield a function that satisfies the fourth property, I fear it would ultimately only be a waste of time. I am hoping there may a more elementary solution.

Literally just $x^n$ LOL.

For nonnegative $n$, as $n$ increases, the average value is closer to zero, and as $n$ decreases towards zero, the average value is closer to $1$.

All other three criteria are fulfilled too.

• Pretty sure you can’t really get c=0 or c=1, but they are APPROACHABLE – Saketh Malyala Jul 1 '17 at 2:27
• But it might not be differentiable at x=0 hm – Saketh Malyala Jul 1 '17 at 2:28
• How would you go about calculating 'n' for a given 'c'? – Mark Jul 1 '17 at 4:54
• gah... stupid question. I figured it out... n=(1-c)/c. Indeed, that does seem to produce to correct result. – Mark Jul 1 '17 at 5:04
• hey that isn't a stupid question! plus you figured it out. pat on the back – Saketh Malyala Jul 1 '17 at 5:08

Yes, you need $c$ to be the integral of the function over the interval. For your function, the integral is $$\frac{k \left(2 k-2 (k-1) \tanh ^{-1}(1-2 k)-1\right)}{(1-2 k)^2},$$ so solving for $k$ is not trivial.