| > |
file: Mars.mws
===========
7.3.2004
8.3.2004
------------------------------------------------------------------------
In this Worksheet, I discuss the derivation of the
Importance weights as function of the location size,
such that the label density on the screen remains constant
at all distances.
Typical applications will be the crowded locations on Mars and Venus
-------------------------------------------------------------------------
| > | with(plots): |
Warning, the name changecoords has been redefined
| > | with(stats): with(stats[statplots]): |
The file 'Mars_sizes.txt' contains a 1-dim array of (nonvanishing) sizes [km] of the 1327 locations for Mars . Read it into Maple:
| > | data:=readdata("Mars_sizes.txt",float): |
Calculate log base 10 for each element:
| > | size:=evalf(map(log10,data)): |
Histogram plot of log10(size) distribution:
| > | ph:=histogram(size,area=count,axes=boxed,labels=["log10(size)","number of labels"],labeldirections=[horizontal,vertical],OPTS): |
| > | display(ph); |
Extract the numerical values from histogram plot structure 'ph':
| > | Binwidth:=op([1,2],ph)[2][1]-op([1,1],ph)[2][1]; |
| > | dbx:=[];dby:=[];dbxy:=[]; |
| > | for i from 1 to 12 do |
| > | dbx:=[op(dbx),op([1,i],ph)[2][1]+0.5*Binwidth]; |
| > | dby:=[op(dby),op([1,i],ph)[2][2]]; |
| > | dbxy:=[op(dbxy),[op([1,i],ph)[2][1]+0.5*Binwidth,op([1,i],ph)[2][2]]]; |
| > | end do: |
| > | dbxy; |
| > | dbx; |
| > | dby; |
Compute the total number of non-vanishing location sizes in all 12 bins:
| > | GG:=j->sum(dby['i'],'i'=j..12); |
| > | for j from 1 to 12 do |
| > | GG(j); |
| > | od: |
| > | GG(1); |
Aha, they sum up to the total count of (non-vanishing) location sizes in the data base.
Test on a Normal distribution of log10(size) around log10(s0) ,
| > | assume(v>0); |
| > | dnLabels:=sqrt(v/Pi)*binwidth*nLabels_tot*exp(-v*(x-log10(s0))^2); |
| > | int(dnLabels/binwidth,x=-infinity..infinity); |
OK, the distribution correctly integrates to the total number
of Mars locations = 1327 with non-vanishing size
Form ln of y-values (counts), to make the fit function linear in parameters:
| > | YL:=map(x->ln(x),dby); |
Expand the Gaussian exponent and substitute parameters to generate the required linear dependence:
| > | combine(collect(simplify(ln(subs(log10(s0)=x0,dnLabels)),symbolic),[x],factor)); |
| > | Y:=y=subs(v*x0^2=-C+ln(1/Pi^(1/2)*v^(1/2)*binwidth)+ln(nLabels_tot),x0=d/(2*v),combine(collect(simplify(ln(subs(log10(s0)=x0,dnLabels)),symbolic),[x],factor))); |
Do a leastsquare fit of the size data to a Normal distribution:
| > | w:=fit[leastsquare[ [x,y],Y] ]([dbx,YL]); |
solve for the original parameters (x0, nLabels_tot, v):
| > | eq0:=coeff(rhs(w),x,2)=-v; |
| > | eq1:=coeff(rhs(w),x,1)=2*v*x0; |
| > | eq2:=subs(binwidth=Binwidth,coeff(rhs(w),x,0)=-v*x0^2+ln(1/Pi^(1/2)*v^(1/2)*binwidth)+ln(nLabels_tot)); |
| > | ccc:=solve({eq0,eq1,eq2},{v,x0,nLabels_tot}); |
The average location size on Mars is [km]:
| > | S0:=evalf(10^1.775785090); |
| > | pt:=plot(exp(rhs(w)),x=-1..4.5,color=red,thickness=2): |
| > | display({ph,pt},labels=["log10( size )","Number of Labels"],labeldirections=[horizontal,vertical], title="Normal Distribution of log10(size) around log10(s0=59.67)", titlefont=[HELVETICA,20],OPTS); |
OK, not perfect, but quite well compatible with a Normal distribution...
Except for the top bins, the fit goes nicely through the centers of the bins in the
left and right tails of the Normal distribution!
-------------------------------------------------------------------------------------
Next, want to derive the Importance weights I,
such that the label density on the monitor remains always constant!
-------------------------------------------------------------------------------------
Strategy:
=======
i) Let nLabels = ( number of visible labels ) at distance d of our object (Mars, Venus,...),
having an area A(d) =
on screen in [pix^2].
=============================================
Require that the visible label density is about constant
at all distances d [FoV's] of our object, i.e
= constant
=============================================
ii) For the given monitor resolution, and a range of 'importance weights I',
determine empirically the distances d = d_vis(I) of our object, for which
the associated labels just become visible .
It is a linear relation as expected (see below).
d_vis = 14.8 +86.9*I [km]
Thus the requirement of a constant label density turns into a formula
for the importance weights I
iii) On Earth I calculated nLabels = nLabels(population) from
the known data on city populations. For Mars, Venus,...
we may as well take the number-distribution of the
location sizes .
Above we obtained approximately a Normal distribution
nLabels = Normal(log10(size))
around an average location size of s0 = 59.67 km.
iv) We may feed this in and determine the only unknown constant
by requiring a convenient number of visible labels at a certain
distance of the object. E.g. for Earth,
at a distance
of 40000 km.
-------------------------------------------------------------------------
Our problem of expressing the weights as function of the known location sizes
such as to keep the label density on the screen constant, is solved!
Let's get quantitative:
| > | distance:=[187,325,520,999,2085,6107,9835,15708,24880,33900]; |
| > | importance:=[2.2,3.84,6.11,11.49,24.08,70.13,112.72,178.9,285.68,391]; |
| > | distimp:=[[2.2,187],[3.84,325],[6.11,520],[11.49,999],[24.08,2085],[70.13,6107],[112.72,9835],[178.9,15708],[285.68,24880],[391,33900]]; |
| > | q0:=pointplot(distimp,symbol=BOX,color=blue,symbolsize=20): |
Again: least square fit of linear relation: min. distance <=> Importance weight
| > | fit[leastsquare[[x,y],y=a+b*x]]([importance,distance]); |
| > | q1:=plot(14.82791092+86.91039073*imp,imp=1..1000,color=red,thickness=2): |
| > | display({q0,q1},axes=boxed,labels=["Importance weight","min. distance [ km ], where visibility starts"], labeldirections=[horizontal,vertical]); |
Aha, an excellent fit!
--------------------------
Next, since we want the total number of visible labels for a given log10(st)= xt,
we must divide by the binwidth and integrate from xt to 'infinity' (all labels corresponding to a bigger size than xt are also visible!):
| > | Int(exp(rhs(w))/Binwidth,x=xt..infinity)=int(exp(rhs(w))/Binwidth,x=xt..infinity); |
Define a function from the result:
| > | nLabels:=xt->evalf(-675.0777883*erf(.8736884307*xt-1.551482889)+675.0777883); |
Let's see what the total number of labels becomes? Close to 1327?
| > | nLabels(-infinity); |
YES, indeed, it's not at all bad, compared to the exact value of 1327!
Plot the integrated number of totally visible labels vs. xt=log10(st):
| > | plot(nLabels(x),x=-1..4,OPTS,labels=["xt=log10(st)","number of visible labels for sizes >xt"]); |
Next we calculate the Importance weights, as outlined above, from
| > | Importance:=expand(solve(nLabels=(c/(14.82791092+86.91039073*imp))^2,imp)[1]); |
c is the constant to be determined e.g. from the requirement of seeing 10 labels (5/hemisphere) at a distance of 40000km:
For general c, we get:
| > | solve(nLabs=(C/40000)^2,C)[1]; |
====================================Final Result =================================================
| > | Imp:=evalf(subs(nLabels=nLabels(log10(s)),c=40000*nLabs^(1/2),Importance)); |
==============================================================================================
| > | w1:=loglogplot(subs(nLabs=10,Imp),s=0.1..10000,axes=boxed,labels=["Size [km]","Importance Weight"],color=red,OPTS,numpoints=5000): |
| > | w2:=loglogplot(subs(nLabs=20,Imp),s=0.1..10000,axes=boxed,labels=["Size [km]","Importance Weight"],color=blue,numpoints=5000,OPTS): |
| > | w3:=loglogplot(subs(nLabs=5,Imp),s=0.1..10000,axes=boxed,labels=["Size [km]","Importance Weight"],color=green,numpoints=5000,OPTS): |
| > | display({w1,w2,w3}); |
| > |
-------------------------------------------------------------------------------------
This solves the problem, the above function is entered into my Perl script
which assigns the Importance weights accordingly!
--------------------------------------------------------------------------------------