I have a python code to calculate the probability using lognormal distribution function and want to convert it to c++. I tried the boost library but it does not provide the required functionality (as per my findings, please correct me if I am wrong).
df['prob'] = (1 - scipy.stats.lognorm(s=sd, loc=0, scale=math.exp(mean)).cdf(df.cum_size))**exponent
Can anyone help with this?
Related
I watched some many videos on proper codes for generating cross-validation likelihood when smooth kernel a curve and non of the package works well. I need simple codes let's say using "mtcars". Any help with that, please? And if I can change the bandwidth (h) what code to use?
I tried caret but did not work. I hope you can give me proper codes using mtars so I can use the codes for any data I may have.
I have compiled seshat but it requires input in inkml or scgink format. As the code is in cpp I am unable to understand. How can I use this work (seshat) on normal math images?
Any help will be much appreciated!!
Note: I have seen other answers on stack overflow regarding this but I was not able to get them
If any python work is there (Because I am only familiar with python)
or is there any way I could convert normal image to the format that seshat accepts
I am discovering the coder tool in Matlab. some of my code was successfully converted but it fails in functions which contain the functions "sym" for symbolic and "perms" for permutations. Also I seem to get an error when I save the answer "ans" of for example "A==B". Any idea how to solve this problem?
Thank you for your help
Here is an example of parts of my matlab function that cannot be transformed into c++ with coder:
b=4;
s=2;
one=ones(factorial(b),1);
two=2*ones(factorial(b),1);
B=perms(s+1:b+s);
S=[one,two,B];
sz=size(S);
%%%%%%%%%%%%%%%%%%%
L=[1,3;1,4;1,5;1,6;2,3;2,4;2,5;2,6];
x=perms(1:8);
M=[];
Some toolbox functions cannot be compiled, i.e. they can only be run from a MATLAB session. The following post tells us that functionality in the Symbolic toolbox cannot be compiled.
http://se.mathworks.com/matlabcentral/answers/96441-why-am-i-unable-to-compile-functions-from-the-symbolic-math-toolbox
So most likely this is the reason why you are running into problems when you try to run it in compiled form.
More info about compiler support for various toolboxes can be found here:
http://se.mathworks.com/products/compiler/supported/compiler_support.html
Symbolic Math toolbox does not appear on the list and any toolbox that is not listed is not supported (i.e. cannot be compiled).
This question already has answers here:
FileStorage for OpenCV Python API
(6 answers)
Closed 7 years ago.
With openCV you can save/load data with YML or XML format. It is easy with cv::FileStorage using c++ API. I cannot make it work with python API.`
Here is an example of an YML file created using opencv c++ API.
If someone succeed to load it with openCV python API, let me know !
I'm late to the party, but I didn't find any way to do it in pure Python, as the YAML files created by OpenCV (YAML 1.0) aren't wholly compatible, nor easily read with the YAML libraries available in Python (YAML 1.1).
The Python/OpenCV bindings exist, but are just a bunch of C methods with absolutely no documentation, so they're pretty much unusable at this point.
However, writing a small C extension and wrapping it in a class was pretty easy to do, so I suggest you try it out. In case you (or anybody else) still need it, I may be able to release the code of the small module I wrote that, I'll ask that at work on Friday.
To give you some ideas, here is how I use my module :
with FileStorage("my/file.yml") as fs:
print(fs["string"]) # Prints the "string" string key
print(fs["int"]) # Prints the "int" integer key
print(fs["matrixā€¯]) # Prints a matrix (read as a NumPy array)
I'd have thought that google could answer this question, but I've not had much luck.
Does anyone know of any open source C++ implementations of any face detection algorithms other than the Viola-Jones (boosted cascades of Haar-like features) method?
Also, does there exist an open source C++ implementation of Fisherfaces anywhere?
Thanks.
This post gets some attention, so I'd like to update it. I've contributed the face recognition library I wrote to OpenCV, which includes Eigenfaces, Fisherfaces and Local Binary Patterns Histograms at time of writing this. So OpenCV 2.4.2 now comes with everything to get started, see the very detailed documentation:
http://docs.opencv.org/trunk/modules/contrib/doc/facerec/
Now the original answer.
I am the author of the article linked in Kevin's post. Please note that you need to find the eigenvalues of the non-symmetric matrix S_{W}^{-1} S_{B} for the Fisherfaces, I didn't explicitly mention it in my blog. OpenCV only has a solver for symmetric matrices in its current version; since eigenvalues and singular values aren't equivalent for non-symmetric matrices you can't use a SVD either. For my project I have adapted the JAMA solver to C++ for solving the eigenvalue problem for non-symmetric matrices, so there's no need to use an external library for it. The CMakeLists.txt is configured, so Eigen can be used as well, so you have the choice.
Now I've finally found some minutes to implement the Fisherfaces method with the OpenCV2 C++ API and pushed the code into my github account at:
https://github.com/bytefish/opencv/blob/master/lda
The main.cpp shows you how to use the Fisherfaces class and how to use the Linear Discriminant Analysis with the same example as on: http://www.bytefish.de/wiki/pca_lda_with_gnu_octave. It comes as a CMake project, so compiling is as easy as typing:
philipp#mango:~/some/dir$ mkdir build; cd build
philipp#mango:~/some/dir/build$ cmake ..
philipp#mango:~/some/dir/build$ make
philipp#mango:~/some/dir/build$ ./lda
I don't know if it's the preferred Stackoverflow way to post code in the answer, but I think it's a bit too long to post.
Please note two things. (1) I read the images from a CSV file (just like this one), you don't have to care about the order of the labels. (2) I store the eigenvectors by column, while the PCA in OpenCV stores them by row. It's just a matter of personal taste to do so, but I've never seen that for any other solver and so I decided to store them by column.