Frage

I am trying to calculate the false positive and false negative rate using matlab. I have generated an s-curve, with a threshold (vertical line that cuts the curve at some point). All values under the curve to the left of the threshold are false-positives and all values not under the curve to the right of the threshold are false-negatives. I would have to integrate the areas under the curve for the false positives and area_of_rect_to_right_of_threshold - (area under curve to right of threshold) to calculate false negatives. I am getting a weird error when I try the following code in matlab.

    syms p;
    func = (1 - (1 - p^5)^10);
    areaOfRect = (1-threshold)*1; 
    fn = areaOfRect - int(func,p,0,threshold);
    fp = int(func,p,threshold,1);


fn = 2575908626830580620307480425353828014939901186516550645854841225649977931806217173152793134129 ......

fp = 20989145492538166675017041353401970126067731601439729556868060737768716969716535384....

These outputs are very peculiar which makes me feel I'm not using the integrate function in the right way. Any help would be much appreciated.

War es hilfreich?

Lösung

Looks like you are just getting the exact solutions in rational form a/b, the evaluation to floating point should match the numerical integrations

fn_sym = double(fn)
fn_num = areaOfRect - quadl(@(p)(1 - (1 - p.^5).^10),0.01,threshold)
fp_sym = double(fp)
fp_num = quadl(@(p)(1 - (1 - p.^5).^10),threshold,1.01)

Andere Tipps

Your text description says: "All values under the curve to the left of the threshold are false-positives" but your code calculates the integral from your threshold to 1.01, which is the right side. I can't judge which is correct.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top