myrng.c 738 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (C) 1994. James Darrell McCauley. (darrell@mccauley-usa.com)
  3. * http://mccauley-usa.com/
  4. *
  5. * This program is free software under the GPL (>=v2)
  6. * Read the file GPL.TXT coming with GRASS for details.
  7. */
  8. #include <stdio.h>
  9. #include <grass/gis.h>
  10. #include "zufall.h"
  11. int myrng(double *numbers, int n,
  12. int (*rng) (int, double *), double p1, double p2)
  13. {
  14. int i;
  15. rng(n, numbers);
  16. if (rng == zufall) /* uniform */
  17. for (i = 0; i < n; ++i)
  18. numbers[i] -= 0.5, numbers[i] *= 2 * p1;
  19. else if (rng == normalen) /* gaussian */
  20. /* is this how to do transformation? */
  21. for (i = 0; i < n; ++i)
  22. numbers[i] *= p2, numbers[i] += p1;
  23. return 0;
  24. }