0
$\begingroup$

I have an array of chisquare values for two parameters \alpha and a. The array is calculated for function of two parameter \alpha, a

chi2Grid={{0.395593, 0.232106, 0.110422, 0.0325206, 0.000658225, 0.0174253, 
  0.085825, 0.209375, 0.392247, 0.639456, 0.957131, 1.35291, 1.83653, 
  2.42078, 3.12306, 3.96825, 4.99417, 6.26409, 7.90079, 
  10.2218}, {0.380696, 0.220039, 0.101626, 0.0275262, 0.000104039, 
  0.0220911, 0.096673, 0.227608, 0.419389, 0.677475, 1.00862, 1.42135,
   1.92679, 2.53986, 3.28158, 4.18331, 5.29609, 6.71478, 8.6646, 
  12.259}, {0.365874, 0.208112, 0.0930563, 0.0228676, 0.0000309826, 
  0.0274309, 0.108454, 0.247124, 0.4483, 0.717946, 1.06354, 1.4947, 
  2.02422, 2.66977, 3.45722, 4.42741, 5.65285, 7.29133, 
  9.90415}, {0.351132, 0.196334, 0.0847241, 0.0185646, 0.000469146, 
  0.0334902, 0.121235, 0.268029, 0.479141, 0.76112, 1.1223, 1.57362, 
  2.12995, 2.81261, 3.65423, 4.71026, 6.09211, 8.1191}, {0.336475, 
  0.184713, 0.0766435, 0.0146385, 0.00145159, 0.0403192, 0.135095, 
  0.29044, 0.512094, 0.807289, 1.18538, 1.65892, 2.24547, 2.97124, 
  3.87885, 5.0482, 6.67488, 10.2671}, {0.321908, 0.173257, 0.0688292, 
  0.0111128, 0.00301479, 0.0479743, 0.15012, 0.314492, 0.547374, 
  0.8568, 1.25337, 1.75163, 2.37272, 3.14972, 4.14094, 5.4729, 
  7.61229}, {0.307435, 0.161977, 0.0612975, 0.00801346, 0.0051991, 
  0.0565182, 0.166407, 0.34034, 0.585231, 0.910069, 1.32697, 1.85308, 
  2.51435, 3.35412, 4.45781, 6.06479}, {0.293063, 0.150882, 0.0540659,
   0.00536871, 0.00804943, 0.0660217, 0.184069, 0.368164, 0.625961, 
  0.967601, 1.40711, 1.96504, 2.67418, 3.5943, 4.86586}, {0.278798, 
  0.139985, 0.0471537, 0.00320997, 0.0116159, 0.0765646, 0.203234, 
  0.398175, 0.66992, 1.03003, 1.49496, 2.08992, 2.85801, 3.88845, 
  5.48061}, {0.264646, 0.129297, 0.0405821, 0.00157208, 0.0159549, 
  0.088238, 0.224052, 0.430621, 0.71754, 1.09813, 1.59209, 2.23126, 
  3.07559, 4.27914}, {0.250615, 0.118833, 0.0343746, 0.000493874, 
  0.02113, 0.101146, 0.246696, 0.465803, 0.769359, 1.17295, 1.70068, 
  2.39453, 3.34594}, {0.236713, 0.108607, 0.0285571, 0.0000189081, 
  0.0272136, 0.115411, 0.271372, 0.504084, 0.826054, 1.25586, 1.82394,
   2.58921, 3.72082}, {0.222949, 0.0986362, 0.0231585, 0.000196255, 
  0.0342883, 0.131172, 0.298328, 0.545913, 0.888508, 1.34879, 1.96694,
   2.83515}, {0.209331, 0.0889379, 0.0182111, 0.00108158, 0.0424498, 
  0.148596, 0.327862, 0.591863, 0.957907, 1.45459, 2.13877}, {0.19587,
   0.0795326, 0.013751, 0.00273844, 0.0518095, 0.167883, 0.360345, 
  0.642674, 1.03592, 1.57786}, {0.182579, 0.0704428, 0.00981949, 
  0.00524003, 0.0624983, 0.189274, 0.396248, 0.699345, 
  1.12502}, {0.169468, 0.0616936, 0.00646312, 0.00867136, 0.0746726, 
  0.213066, 0.436179, 0.763283}, {0.156553, 0.0533134, 0.00373552, 
  0.0131322, 0.0885214, 0.239636, 0.480959}, {0.143849, 0.0453344, 
  0.00169872, 0.018741, 0.104277, 0.269473}, {0.131374, 0.0377931, 
  0.000425171, 0.0256405}} 


    (*Find the minimum chi-squared value and its indices*)
    chi2Min = Min[chi2Grid];
    minIndex = Position[chi2Grid, chi2Min][[1]];
    alphaRange = Range[0.001, 1.687275, 0.08436];
    alphaBest = alphaRange[[minIndex[[1]]]];
    aRange = Range[0.001, amax[alphaBest], 
      0.05];(*Ensure aRange is defined*)aBest = 
    aRange[[minIndex[[2]]]];
    
    (*Define confidence levels*)
    deltaChi2 = {2.30, 
      6.18};(*1-sigma,2-sigma for 2 parameters*)contourLevels = 
     chi2Min + deltaChi2;
    
    (*Plot the confidence contours*)
    ListContourPlot[chi2Grid, 
     DataRange -> {{Min[alphaRange], Max[alphaRange]}, {Min[aRange], 
        Max[aRange]}}, Contours -> contourLevels, ContourLabels -> True, 
     ContourStyle -> {{Blue, Thick}, {Green, Thick}}, PlotRange -> All, 
     FrameLabel -> {"\[Alpha]", "a"}, 
     PlotLegends -> Placed[{"1\[Sigma]", "2\[Sigma]"}, Bottom], 
     Epilog -> {Red, PointSize[Large], Point[{alphaBest, aBest}], 
       Text[Style[
         "Best Fit: \[Alpha]=" <> ToString[alphaBest] <> ", a=" <> 
          ToString[aBest], Bold, Red], {alphaBest, aBest + 0.5}]}, 
     Frame -> True, PlotLabel -> "Confidence Contours for \[Alpha] and a"]

and I want to make a ListContourPlot of this list for which I have written this code above. Can someone help me to interpolate this dataset so that it become a valid array for ListContourPlot.

$\endgroup$
3
  • $\begingroup$ Select[Range[0.001, 1.687275, 0.08436]] is wrong syntax $\endgroup$ Commented Dec 6 at 8:32
  • $\begingroup$ i have removed the select function. now it should be good $\endgroup$
    – Amnish
    Commented Dec 8 at 6:29
  • $\begingroup$ "amax" is not defined. You can detect undefined variables by their color. $\endgroup$ Commented Dec 8 at 8:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.