Skip to content

Instantly share code, notes, and snippets.

@cbguder
Created March 7, 2011 15:43
Show Gist options
  • Save cbguder/858653 to your computer and use it in GitHub Desktop.
Save cbguder/858653 to your computer and use it in GitHub Desktop.
Weibull distribution
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
float randomf() {
return (float)random() / (float)RAND_MAX;
}
float weibull(float alpha, float beta) {
float u = 1.0 - randomf();
return alpha * pow(-log(u), 1.0/beta);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment