# Discrete Probability Distribution with Lists

I'm trying to create a piecewise function with y values {.1, .2, .342, .353,...,.9} and x-values {1, 2, 3, 4,...,n}. My end goal is to do this: Define a simple discrete probability distribution and then calculate x-values given y-values. For example, given 0.11, I should get back 2. Given 0.05, I should get back 1. Etc.

So far, I've tried

 Piecewise[{distrib[[x]], 0 < x < Length[distrib]}]


This didn't work (I don't know why)

and

 Distrib = ProbabilityDistribution[distrib[[x]], {x, 1, Length[distrib]}]


This wouldn't let me create an InverseCDF.

Any suggestions?

Here's an example:

x = Range[1, 5];
p = {0.1, 0.1, 0.142, 0.3, 0.358};
data = Transpose[{x, p}];
prob[x_] := Piecewise[{#[], x == #[]} & /@ data, 0]
discrete = ProbabilityDistribution[prob[i], {i, 1, Length[x], 1}] InverseCDF[discrete, 0.11]
(* 2 *)
InverseCDF[discrete, 0.05]
(* 1 *)


I'm not certain of your goals. Are you looking for the following?

f =(1 + Count[yvals, x_ /; x <= #]) &