# How is the subtraction of a uniform (0, k) and its entire part distributed?

Let X be a random variable distributed as $$U[0, K]$$ for an integer K. Find the density function of $$Y = f (x) = x- [x]$$, where [x] denotes the integer part of the real number x.

I think that [X] represents a discrete uniform but this by definition would be with values at x = 1,2, ... k, and its density would be 1/k which is the same as that of the continuous uniform.

Now, I understand that the distribution [X] is dependent on X, then I could not assume independence to use some kind of transformation because I do not know the joint.

I appreciate if you can give me some other way that I have not considered, thank you very much.

So, set $$\{x\}=x-\lfloor x\rfloor$$ to be the fractional part of $$x$$. Check that $$\{x\} \in [0,1)$$. Hence, $$f_X(x)$$ is defined for $$x\in [0,1)$$. Let's compute the CDF. Fix a $$c\in[0,1)$$, and study $$\mathbb{P}(\{x\}\leq c)$$. Observe that, $$\{\{x\} \leq c\}=\bigcup_{k=0}^{K-1}\{x\in [k,k+c)\},$$ hence $$\mathbb{P}(\{x\}\leq c)=K\cdot \frac{c}{K}=c$$. Hence, it turns out that, $$\{x\}$$ is uniform on $$[0,1)$$ (and also, $$\lfloor x\rfloor$$ is uniform on $$\{0,\dots,K-1\}$$.