Merged master 8748
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
subroutine foxfilt(nslots,nfreq,width,wave)
|
||||
|
||||
parameter (NN=79,ND=58,KK=87,NSPS=4*1920)
|
||||
parameter (NWAVE=NN*NSPS,NFFT=614400,NH=NFFT/2)
|
||||
real wave(NWAVE)
|
||||
real x(NFFT)
|
||||
complex cx(0:NH)
|
||||
equivalence (x,cx)
|
||||
|
||||
x(1:NWAVE)=wave
|
||||
x(NWAVE+1:)=0.
|
||||
call four2a(x,NFFT,1,-1,0) !r2c
|
||||
df=48000.0/NFFT
|
||||
fa=nfreq - 0.5*6.25
|
||||
fb=nfreq + 7.5*6.25 + (nslots-1)*60.0
|
||||
ia2=nint(fa/df)
|
||||
ib1=nint(fb/df)
|
||||
ia1=nint(ia2-width/df)
|
||||
ib2=nint(ib1+width/df)
|
||||
pi=4.0*atan(1.0)
|
||||
do i=ia1,ia2
|
||||
fil=(1.0 + cos(pi*df*(i-ia2)/width))/2.0
|
||||
cx(i)=fil*cx(i)
|
||||
enddo
|
||||
do i=ib1,ib2
|
||||
fil=(1.0 + cos(pi*df*(i-ib1)/width))/2.0
|
||||
cx(i)=fil*cx(i)
|
||||
enddo
|
||||
cx(0:ia1-1)=0.
|
||||
cx(ib2+1:)=0.
|
||||
|
||||
call four2a(cx,nfft,1,1,-1) !c2r
|
||||
wave=x(1:NWAVE)/nfft
|
||||
|
||||
return
|
||||
end subroutine foxfilt
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 33 KiB |
@@ -0,0 +1,468 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LogQSO</class>
|
||||
<widget class="QDialog" name="LogQSO">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>377</width>
|
||||
<height>257</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_11">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Click OK to confirm the following QSO:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lab1">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Call</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="call"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="lab2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDateTimeEdit" name="start_date_time">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="displayFormat">
|
||||
<string>dd/MM/yyyy HH:mm:ss</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="lab2_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>End</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDateTimeEdit" name="end_date_time">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="displayFormat">
|
||||
<string>dd/MM/yyyy HH:mm:ss</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="lab4">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="mode">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="lab5">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Band</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="band">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="lab6">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rpt Sent</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="sent">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<item>
|
||||
<widget class="QLabel" name="lab7">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rpt Rcvd</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="rcvd">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
<widget class="QLabel" name="lab8">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Grid</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="grid">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
<item>
|
||||
<widget class="QLabel" name="lab9">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="name">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Tx power</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="txPower"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbTxPower">
|
||||
<property name="text">
|
||||
<string>Retain</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lab10">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Comments</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="comments">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbComments">
|
||||
<property name="text">
|
||||
<string>Retain</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="operatorLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Operator</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="loggedOperator">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>call</tabstop>
|
||||
<tabstop>start_date_time</tabstop>
|
||||
<tabstop>end_date_time</tabstop>
|
||||
<tabstop>mode</tabstop>
|
||||
<tabstop>band</tabstop>
|
||||
<tabstop>sent</tabstop>
|
||||
<tabstop>rcvd</tabstop>
|
||||
<tabstop>grid</tabstop>
|
||||
<tabstop>name</tabstop>
|
||||
<tabstop>txPower</tabstop>
|
||||
<tabstop>cbTxPower</tabstop>
|
||||
<tabstop>comments</tabstop>
|
||||
<tabstop>cbComments</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>LogQSO</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>LogQSO</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -1,266 +0,0 @@
|
||||
/* RAND-TEST.C - Program to test random number generators. */
|
||||
|
||||
/* Copyright (c) 1995-2012 by Radford M. Neal.
|
||||
*
|
||||
* Permission is granted for anyone to copy, use, modify, and distribute
|
||||
* these programs and accompanying documents for any purpose, provided
|
||||
* this copyright notice is retained and prominently displayed, and note
|
||||
* is made of any changes made to these programs. These programs and
|
||||
* documents are distributed without any warranty, express or implied.
|
||||
* As the programs were written for research purposes only, they have not
|
||||
* been tested to the degree that would be advisable in any important
|
||||
* application. All use of these programs is entirely at the user's own
|
||||
* risk.
|
||||
*/
|
||||
|
||||
|
||||
/* Usage:
|
||||
|
||||
rand-test seed generator { parameters } / sample-size [ low high bins ]
|
||||
|
||||
Using the seed given, tests the random number generator identified by
|
||||
the second argument, for the parameter values specified. The possible
|
||||
generators and required parameters are as follows:
|
||||
|
||||
uniform Uniform from [0,1)
|
||||
uniopen Uniform from (0,1)
|
||||
int n Uniform from the set { 0, 1, ..., (n-1) }
|
||||
gaussian From Gaussian with mean zero and unit variance
|
||||
exp From exponential with mean one
|
||||
cauchy From Cauchy centred at zero with unit width
|
||||
gamma alpha From Gamma with shape parameter (and mean) alpha
|
||||
beta a b From Beta with parameters a and b
|
||||
|
||||
The size of the sample to use is also specified. The program reports
|
||||
the mean and variance of the sample. A histogram is also printed if a
|
||||
low and high range and number of bins are for it are specified.
|
||||
|
||||
These tests are not really adequate to detect subtle forms of bias due
|
||||
to use of pseudo-random numbers, but are hopefully good enough to find
|
||||
most programming errors.
|
||||
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "rand.h"
|
||||
|
||||
|
||||
#define Max_bins 1000 /* Maximum number of histogram bins */
|
||||
|
||||
static void usage (void);
|
||||
|
||||
|
||||
/* MAIN PROGRAM. */
|
||||
|
||||
main
|
||||
( int argc,
|
||||
char **argv
|
||||
)
|
||||
{
|
||||
int seed, sample_size, bins, np;
|
||||
double low, high;
|
||||
char *generator;
|
||||
double p1, p2;
|
||||
|
||||
double mean, variance;
|
||||
double tmean, tvariance;
|
||||
int undef_mean, undef_variance;
|
||||
|
||||
int count[Max_bins];
|
||||
int under, over;
|
||||
|
||||
char **ap;
|
||||
double x;
|
||||
int i, n;
|
||||
|
||||
bins = 0;
|
||||
|
||||
if (argc<5) usage();
|
||||
|
||||
if ((seed = atoi(argv[1]))==0 && strcmp(argv[1],"0")!=0) usage();
|
||||
|
||||
generator = argv[2];
|
||||
|
||||
if (strcmp(generator,"uniform")==0) np = 0;
|
||||
else if (strcmp(generator,"uniopen")==0) np = 0;
|
||||
else if (strcmp(generator,"int")==0) np = 1;
|
||||
else if (strcmp(generator,"poisson")==0) np = 1;
|
||||
else if (strcmp(generator,"gaussian")==0) np = 0;
|
||||
else if (strcmp(generator,"exp")==0) np = 0;
|
||||
else if (strcmp(generator,"cauchy")==0) np = 0;
|
||||
else if (strcmp(generator,"gamma")==0) np = 1;
|
||||
else if (strcmp(generator,"beta")==0) np = 2;
|
||||
else
|
||||
{ fprintf(stderr,"Unknown generator: %s\n",generator);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ap = argv+3;
|
||||
|
||||
if (np>0)
|
||||
{ if (*ap==0 || (p1 = atof(*ap++))<=0) usage();
|
||||
}
|
||||
if (np>1)
|
||||
{ if (*ap==0 || (p2 = atof(*ap++))<=0) usage();
|
||||
}
|
||||
|
||||
if (*ap==0 || strcmp(*ap++,"/")!=0) usage();
|
||||
|
||||
if (*ap==0 || (sample_size = atoi(*ap++))<=0) usage();
|
||||
|
||||
if (*ap!=0)
|
||||
{ low = atof(*ap++);
|
||||
if (*ap==0) usage();
|
||||
high = atof(*ap++);
|
||||
if (high<=low) usage();
|
||||
if (*ap==0 || (bins = atoi(*ap++))<=0) usage();
|
||||
if (bins>Max_bins)
|
||||
{ fprintf(stderr,"Too many histogram bins\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (*ap!=0) usage();
|
||||
|
||||
printf("\nTest of %s(",generator);
|
||||
if (np>0) printf("%.4f",p1);
|
||||
if (np>1) printf(",%.4f",p2);
|
||||
printf(") generator using sample of size %d with seed %d\n\n",
|
||||
sample_size, seed);
|
||||
|
||||
undef_mean = undef_variance = 0;
|
||||
|
||||
if (strcmp(generator,"uniform")==0)
|
||||
{ tmean = 0.5;
|
||||
tvariance = 1.0/12.0;
|
||||
}
|
||||
else if (strcmp(generator,"uniopen")==0)
|
||||
{ tmean = 0.5;
|
||||
tvariance = 1.0/12.0;
|
||||
}
|
||||
else if (strcmp(generator,"int")==0)
|
||||
{ tmean = (p1-1)/2;
|
||||
tvariance = p1*p1/3.0 - p1/2.0 + 1/6.0 - tmean*tmean;
|
||||
}
|
||||
else if (strcmp(generator,"poisson")==0)
|
||||
{ tmean = p1;
|
||||
tvariance = p1;
|
||||
}
|
||||
else if (strcmp(generator,"gaussian")==0)
|
||||
{ tmean = 0;
|
||||
tvariance = 1;
|
||||
}
|
||||
else if (strcmp(generator,"exp")==0)
|
||||
{ tmean = 1;
|
||||
tvariance = 1;
|
||||
}
|
||||
else if (strcmp(generator,"cauchy")==0)
|
||||
{ undef_mean = 1;
|
||||
undef_variance = 1;
|
||||
}
|
||||
else if (strcmp(generator,"gamma")==0)
|
||||
{ tmean = p1;
|
||||
tvariance = p1;
|
||||
}
|
||||
else if (strcmp(generator,"beta")==0)
|
||||
{ tmean = p1 / (p1+p2);
|
||||
tvariance = (p1*p2) / ((p1+p2)*(p1+p2)*(p1+p2+1));
|
||||
}
|
||||
else
|
||||
{ abort();
|
||||
}
|
||||
|
||||
mean = 0;
|
||||
variance = 0;
|
||||
|
||||
if (bins>0)
|
||||
{ for (i = 0; i<bins; i++) count[i] = 0;
|
||||
under = over = 0;
|
||||
}
|
||||
|
||||
rand_seed(seed);
|
||||
|
||||
for (n = 0; n<sample_size; n++)
|
||||
{
|
||||
if (strcmp(generator,"uniform")==0) x = rand_uniform();
|
||||
else if (strcmp(generator,"uniopen")==0) x = rand_uniopen();
|
||||
else if (strcmp(generator,"int")==0) x = rand_int((int)p1);
|
||||
else if (strcmp(generator,"poisson")==0) x = rand_poisson(p1);
|
||||
else if (strcmp(generator,"gaussian")==0) x = rand_gaussian();
|
||||
else if (strcmp(generator,"exp")==0) x = rand_exp();
|
||||
else if (strcmp(generator,"cauchy")==0) x = rand_cauchy();
|
||||
else if (strcmp(generator,"gamma")==0) x = rand_gamma(p1);
|
||||
else if (strcmp(generator,"beta")==0) x = rand_beta(p1,p2);
|
||||
else abort();
|
||||
|
||||
mean += x;
|
||||
variance += x*x;
|
||||
|
||||
if (bins>0)
|
||||
{ if (x<low)
|
||||
{ under += 1;
|
||||
}
|
||||
else
|
||||
{ i = (int) ((x-low)/((high-low)/bins));
|
||||
if (i>=bins)
|
||||
{ over += 1;
|
||||
}
|
||||
else
|
||||
{ count[i] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mean /= sample_size;
|
||||
variance /= sample_size;
|
||||
variance -= mean*mean;
|
||||
|
||||
printf("Sample mean: %.4f",mean);
|
||||
if (undef_mean)
|
||||
{ printf(" (true value: undefined)\n");
|
||||
}
|
||||
else
|
||||
{ printf(" (true value: %.4f)\n",tmean);
|
||||
}
|
||||
|
||||
printf("Sample variance: %.4f",variance);
|
||||
if (undef_variance)
|
||||
{ printf(" (true value: undefined)\n");
|
||||
}
|
||||
else
|
||||
{ printf(" (true value: %.4f)\n",tvariance);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
if (bins!=0)
|
||||
{ printf("Histogram:\n");
|
||||
printf(" under : %8d %.5f\n\n",
|
||||
under, (double)under / sample_size);
|
||||
for (i = 0; i<bins; i++)
|
||||
{ printf(" %10.4f - %10.4f : %8d %.5f\n",
|
||||
i*(high-low)/bins + low, (i+1)*(high-low)/bins + low,
|
||||
count[i], (double)count[i] / sample_size);
|
||||
}
|
||||
printf("\n over : %8d %.5f\n",
|
||||
over, (double)over / sample_size);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
/* PRINT USAGE MESSAGE AND EXIT. */
|
||||
|
||||
static void usage (void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: rand-test seed generator { parameters } / sample-size [ low high bins ]\n");
|
||||
|
||||
exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user