#include #include #include #include "idc.h" /********************************************************************** * * * File: misuquan.c * * Function: exploration of the effect of mismatch on uniform * * quantization. * * Author : K. Sayood * * Last mod: 7/15/95 * * Usage: see usage(), for details see misnuq.doc or man page * ***********************************************************************/ /******************************************************************************* *NOTICE: * *This code is believed by the author to be bug free. You are free to use and * *modify this code with the understanding that any use, either direct or * *derivative, must contain acknowledgement of its author and source. The author* *makes no warranty of any kind, expressed or implied, of merchantability or * *fitness for a particular purpose. The author shall not be held liable for any* *incidental or consequential damages in connection with or arising out of the * *furnishing, performance, or use of this software. This software is not * *authorized for use in life support devices or systems. * ********************************************************************************/ void usage(void); void main(int argc, char *argv[]) { float mean, var, secmom, qerr, msqe, snr, scale; float input, output,stepsize,low,prob[256], entropy; int i, num, numlev,numbits,label, distribution, ent_flag; float min_std, max_std, std_step; int c, seed; extern int optind; extern char *optarg; seed = 0; zufalli_(seed); num = -1; numlev = -1; stepsize = -1.0; distribution = -10; ent_flag = 0; min_std = .3; max_std = 3.; std_step = .1; while((c=getopt(argc,argv,"l:q:n:d:b:m:s:eh"))!=EOF) { switch (c){ case 'l': sscanf(optarg,"%d",&numlev); break; case 'q': sscanf(optarg,"%f",&stepsize); break; case 'n': sscanf(optarg,"%d", &num); break; case 'd': sscanf(optarg,"%d", &distribution); break; case 'b': sscanf(optarg,"%f", &min_std); break; case 'm': sscanf(optarg,"%f", &max_std); break; case 's': sscanf(optarg,"%f", &std_step); break; case 'e': ent_flag++; break; case 'h': usage(); exit(1); } } if(numlev < 0){ printf("Enter number of levels\n"); scanf("%d",&numlev);} if(stepsize < 0.){ printf("Enter stepsize\n"); scanf("%f",&stepsize);} if(num < 0){ printf("Enter # of #s to test \n"); scanf("%d",&num);} if(distribution < 0){ printf(" What is the probability model for the input\n"); printf(" Enter 0 for uniform\n"); printf(" 1 for Gaussian\n"); printf(" 2 for Laplacian\n"); scanf("%d",&distribution);} numbits = (int) (log((double) numlev)/log((double) 2.) + 0.99999); /* Are the number of levels even or odd */ if((numlev/2)*2 == numlev) low = (float) -(numlev/2 - 1)* stepsize; else low = (float) -((numlev/2)* stepsize -stepsize/2); for(scale=min_std; scale