Posts

Showing posts from December 15, 2018

calculate p-values from cdf and show them in a graph

Image
up vote -2 down vote favorite 1 I have plotted the cdf of my dataset. I would like to know find out some p-values (probabilities), I could do it looking at the graph, however, I would like to know if there is a way to do it with a python code and show it in the graph. I have the following code x = np.sort(df['Consumption KW']) y = np.arange(1,len(x)+1)/len(x) plt.plot(x,y,marker='.',linestyle='none', label='Consumption KW') And I get something like this: However, I would like to calculate the value of KW (x-axis) with a probability of 93% (I other words when the CDF(0.93)). The following graph shows what I want but with another data set: Does anybody know how to calculate p-values and show them on a graph as aforementioned? It would be of great help! Thanks

count number of partitions of a set with n elements into k subsets

Image
up vote 6 down vote favorite 1 This program is for count number of partitions of a set with n elements into k subsets I am confusing here return k*countP(n-1, k) + countP(n-1, k-1); can some one explain what is happening here? why we are multiplying with k? NOTE->I know this is not the best way to calculate number of partitions that would be DP // A C++ program to count number of partitions // of a set with n elements into k subsets #include<iostream> using namespace std; // Returns count of different partitions of n // elements in k subsets int countP(int n, int k) { // Base cases if (n == 0 || k == 0 || k > n) return 0; if (k == 1 || k == n) return 1; // S(n+1, k) = k*S(n, k) + S(n, k-1) return k*countP(n-1, k) + countP(n-1, k-1); } // Driver program int ma