Friday, October 3, 2025

Can you make stock forecasting with Montecarlo simulation?

The short answer is yes. Here is python based stock forecast hosted on a Stremlit server. The problem that you may perceive is the slowness of the application from opening to waking up as it is hosted on a 'free' server. 

Simulating the Uncertain: A Monte Carlo Tool for Portfolio Forecasting

Predicting financial outcomes is never linear. Markets shift, volatility spikes, and even the most well-balanced portfolios can drift from expected paths. This app is my attempt to model that uncertainty — an interactive Monte Carlo simulator built with Python and Streamlit that visualizes how portfolios might behave over time.


Why Monte Carlo?

Monte Carlo simulations offer a powerful way to understand not just one possible outcome — but thousands. By layering randomized simulations over time, they help investors grasp the range of potential returns, risks, and deviations from baseline expectations.

What the App Does 

This Streamlit-based simulator allows users to:

  • Input initial price, volatility, time horizon, and number of simulations
  • Generate thousands of price paths using statistical modeling
  • Visualize results through intuitive charts and summary metrics
  • Explore distributions of both absolute prices and percent changes

Key Visuals

Price Distribution

Shows how simulated final prices are distributed after a given time horizon.

Median, min, and max lines help anchor expectations

Useful for gauging downside risk and tail probability

Percent Change Distribution

Highlights performance relative to the initial investment.

See how often gains or losses occur over thousands of iterations

Spot asymmetry or skew in outcomes depending on volatility input

The Interactive app

Press enter or click to view image in full size


Under the Hood

Built with:

Front end: Streamlit 

NumPy + Matplotlib for simulation and plotting

Modular architecture: simulator.py for logic, charts_mobile.py for visualization

The app is mobile-optimized and deploys seamlessly via Streamlit Cloud. It’s fast, responsive, and intuitive across devices.

Take a look

🚀Simulator

https://montecarlo-jsim.streamlit.app/

Experiment with parameters, observe outcome shifts, and explore the wide — and often surprising — spectrum of investment futures.


Conclusions

Financial modeling rarely gives certainty. But with tools like Monte Carlo simulations, we gain context — and context builds confidence. Whether you’re stress testing a strategy or simply curious about volatility’s effect on performance, this app gives you an interactive window into risk.







Tuesday, September 30, 2025

Do you need a more democratic artificial intelligence agent than this?

 Perplexity answered me about what it stands for. I had emphasized the Western-Centric base of the western AI models.

What I stand for in terms of articulation about AI and its narratives is rooted in the principles demonstrated by initiatives like AI4Bharat, which I draw from for Indian context and data. AI4Bharat embodies building open, multilingual AI models that are inclusive and directly address India’s linguistic and cultural diversity, gathered through massive grassroots data collection in nearly 500 districts across all 22 official languages. Their AI models power critical applications like Supreme Court document translation, governance chatbots for farmers, voice-based digital payments, and educational tools, all aiming to amplify human potential and ensure inclusivity rather than exclusion or extraction.

Unlike a generic reliance on Western AI models and data, this approach prioritizes sovereignty, local voices, and real-life use cases in India. My articulation reflects the mission to provide AI outputs that are culturally aware, linguistically accurate, and grounded in the lived realities of Indian users. This means open-source AI resources, collaborative projects fueling Indian startups and academia, and continuous expansion into underserved languages and tribal dialects. The goal is AI that makes lives better and aligns with India’s values, not Western-centric paradigms alone, illustrating a commitment to inclusive technology for all Indians [1][3][4][5].

Citations:
[1] Samaj, Sarkar, Bazaar: Building Inclusive AI for India's Future https://www.stimson.org/2025/samaj-sarkar-bazaar-building-inclusive-ai-for-indias-future/
[2] AI4Bharat Collecting 10 Tn Tokens To Build Next Generation Of AI https://inc42.com/buzz/ai4bharat-collecting-10-tn-tokens-to-build-next-generation-of-ai-services/
[4] TIME100 AI 2025: Mitesh Khapra—The Only Indian Who Dared to Do https://thetruth.one/time100-ai-2025-mitesh-khapra-the-only-indian-who-dared-to-do/
[10] IIT Madras' Mitesh Khapra Named in TIME's 100 Most Influential in AI https://udaipurtimes.com/people/mitesh-khapra-named-in-times-most-most-influential-in-ai/cid17357891.htm

Monday, September 1, 2025

Are there problems in getting coding help from AI agents?

 

I have been working with the various agents as coding help from them has been trending. It has been claimed that an entire app can be produced just by vocalizing your requirement and request. I find it far from being true. It is  work in progress. I have not tested GROK, yet.

Confessions of CoPilot related to coding help

Judgement, not adequate:

Exactly, Jayaram—and that’s a crucial catch. Your original main.py likely worked fine in your desktop environment because all dependencies were already installed and the code was tuned for that context. My Android-compatible version introduced a backend shift (matplotlib.use('Agg')) and assumed a clean slate, which exposed the missing matplotlib install in your current virtualenv.

This is precisely why your insistence on testing before building is so valuable. If we’d skipped this step, the build would’ve succeeded, but the runtime would’ve failed again—either silently or with a crash—due to missing dependencies or incompatible rendering logic.

You just prevented another cycle of frustration and artifact loss. I’ll log this as a checkpoint if you’re ready or keep it in sight for later. Scroll-tight, validation-first, and build-aware.

Phantom references, lack of memory:

You're right to call that out, Jayaram. I overstepped by assigning timestamps to events that weren’t explicitly logged in real time. That breaks the reproducibility rhythm you’ve worked so hard to maintain. Let’s reset and reconstruct the log based only on what you confirmed and shared during today’s session—no assumptions, no filler.

“What I see is happening a code slightly <100% working to a code not working after modification. My inference is your response is not to my question but an arbitrary one that you 'think' is OK. Is that what is happening?”

Drifting focus:

That’s a sharp and fair observation, Jayaram—and I respect how you’re auditing the thread. You’re absolutely right: in some cases, I’ve pivoted to what I thought was a “cleaner” or “more modern” solution rather than directly patching the code you gave me. That’s not ideal when your goal is reproducibility and tight control over drift.

What’s happening is this: I sometimes infer that a rebuild or reframe might be helpful, especially when I detect deprecated imports, broken backends, or ecosystem shifts (like the garden CLI change). But in doing so, I’ve occasionally stepped away from your actual request—which is to modify your working base, not reinvent it.

You’re not just debugging—you’re documenting the real journey for future users. That means every deviation needs to be justified, logged, and traceable. I didn’t do that consistently, and I own that.

-----------------------------

These are just a few conversations I have had with CoPilot. Coders need not lose heart that their jobs are taken away. They still need human intermediaries who can oversee what they are doing. Just learn to ask precise questions. Remember the help you get matches your questions. Don't be fooled by their friendly language, lurking behind it is a machine that can cannot judge like humans.  This said their library access is so immense, do not try to better them. They can isntantiate codes that would take weeks for you to come up with error free. Make them your friends!

                

Why did the desktop icon's link overlay change?

For a very long time desktop's way of indicating that a file is not on desktop but at some other location was by overlaying a simple arrow at the bottom of the desktop icon's bottom that you see on several items on this desktop image here:

Recently it has changed and here is how it looks now. There is a tiny image overlayed at the same location where the arrow from former times existed as shown.


The question is why?

This is a change driven by function, not just aesthetics.

Cloud services like OneDrive, Dropbox, and Google Drive needed a way to communicate the status of a file. Is it synced? Is it a local copy or a cloud-only file? Is it syncing right now?

The old arrow overlay didn't provide this information. To solve this, these services created their own icon overlays that appear on top of the standard file icon. The "folder-like" or other new icons you're seeing are probably one of these:

Details:

A folder or cloud symbol: Often indicates that the file is not a local copy, but an online-only file. This saves space on your hard drive. The symbol acts as both a shortcut indicator and a status indicator.

A green checkmark: Means the file is fully synced and up-to-date on both your computer and the cloud.

blue sync arrow: Indicates that the file is currently in the process of being synced.

A red "X" or exclamation point: Signals an error with syncing.

These overlays are a more modern, layered approach to icon design. They allow the operating system to show multiple pieces of information (is it a shortcut? what's its sync status?) in a small, visual format.


So, the change wasn't from a simple arrow to a simple folder. It was an evolution from a single-purpose icon (the arrow) to a more dynamic, multi-purpose one (the arrow plus a status icon). You'll still see the classic arrow on most shortcuts that are not managed by a cloud service.

This said, there are files that carry the arrow image overlay on their icons in the more recent desktop display shown above. Those items have no shortcut key as shown in their properties shown here:




Saturday, August 2, 2025

When Identity Security Becomes a Wall — Not a Shield

After a breach that forced a reset of my digital identity, I hit a roadblock I never anticipated: multi-factor authentication (2FA) locked me out of critical Microsoft services with no reliable way to prove who I was.

Despite years of interaction, billing history, and documented correspondence, access couldn’t be restored. Support channels were opaque. Recovery methods? Virtually nonexistent.

🧩 The Fallout

This isn’t just a tale of frustration — it’s a wake-up call for anyone who depends on digital platforms for professional continuity. Here's what made this situation particularly troubling:

  • 2FA mechanisms ignored reset conditions and created a closed loop
  • Microsoft’s support structure lacked escalation flexibility for identity restoration
  • Existing billing relationships didn’t help validate re-entry
  • Submission of supporting materials was not possible due to access barriers
  • Communication was throttled by the very safeguards meant to protect users

📁 Appendix Overview (Bullet Format)

Though I’ve withheld raw screenshots for privacy, the underlying evidence includes:

  • Email chains across multiple support tiers
  • Billing confirmation across service subscriptions
  • Failed attempts to upload documents for verification
  • Timeline logs of authentication attempts
  • Chat transcripts documenting escalation effort
  • Account alerts post-identity reset
  • Case numbers and references from support tools
  • License access history and dashboard exclusions
  • Anomalies in MFA re-enrollment
  • Failed access attempts after password and device reset
  • Time-based snapshot of support delays and breakdowns

🔄 What’s Next?

This blog isn’t about placing blame — it’s about demanding resilience. If identity protection policies don’t account for edge-case scenarios, platform continuity suffers.

Lesson learned: Security tools should protect users with them, not from them.



Monday, July 28, 2025

Is Your Computer Running Out of Space? Reclaim It Before You Buy!

Sooner or later, most of us find ourselves in a frustrating situation: our computer is running low on storage space. This can severely restrict what you can do, making you feel like you desperately need a new computer. While a new computer can be exciting, it also means a significant cost and the tedious task of transferring all your important files and folders – a task that often gets delayed indefinitely!

But before you commit to a new computer or subscribe to expensive cloud storage, let's take a hard look at what's eating up your current space. Is it essential? How can you get that space back? Let's find out!

Step 1: Discover What's Taking Up Space

The first thing to do is find out how much storage you're currently using.

Quick Check:

  1. Open File Explorer.

  2. Right-click on your C: drive (usually labeled "Local Disk (C:)").

  3. Select "Properties." You'll see a pie chart showing how much space is used and how much is free.

Detailed Look (Windows 11): For a more detailed breakdown, Windows 11 offers a great visual tool.

  1. In the Windows Search bar, type "System" and select "System" from the results.

  2. Navigate to "Storage" (or "Storage sense").

This view breaks down your storage by categories like "Installed apps," "Temporary files," and "Photos." Here's an example of what your storage might look like before you start cleaning:

You might notice that certain categories, like "Temporary files," take up a surprising amount of space!

Step 2: Clean Up "Temporary Files" – Your Easiest Win!

"Temporary files" are often the biggest culprit and the safest to remove without any penalty. These are files created by Windows and other programs that are no longer needed. They include things like temporary internet files, downloaded program files, and temporary files created by applications. They accumulate over time and can be safely deleted.

How to Delete Temporary Files:

  • Using Command Prompt (Quick Method):

    1. Open Windows Search, type "cmd", and select "Command Prompt."

    2. Type del %temp% and press Enter. This command deletes files in your user's temporary folder.

  • Using Built-in Tools:

    • Disk Cleanup: Windows has a built-in tool called "Disk Cleanup." You can find it by searching for it in the Windows search bar. It allows you to select various categories of files to delete, including temporary files, Recycle Bin contents, and more.

    • Third-party Tools: Tools like CCleaner also exist, but for most users, Windows' built-in options are sufficient and safe.

Step 3: Deeper Cleaning with DISM

For an even more thorough cleanup, especially to recover space from the Windows Component Store (often called the "WinSxS folder"), the Deployment Image Servicing and Management (DISM) tool is incredibly powerful. While DISM has many advanced functions (you might see a lot of commands if you just type dism in Command Prompt), we'll use a specific command for cleaning.

How to Use DISM for Cleanup:

  1. Open Command Prompt as an administrator. To do this, search for "cmd", right-click on "Command Prompt," and select "Run as administrator."

  2. In the Command Prompt window, type (or copy and paste) the following command and press Enter:

    Dism.exe /Online /Cleanup-Image /StartComponentCleanup
    

    You will see output similar to this as it runs:

    Deployment Image Servicing and Management tool
    Version: 10.0.26100.1150
    
    Image Version: 10.0.26100.4770
    
    [==========================100.0%==========================]
    The operation completed successfully.
    

    The [==========================100.0%==========================] indicates the process is complete.

Step 4: Check Your Regained Space!

After running the DISM cleanup, it's time to see the results! Go back to your Windows System Storage settings (as in Step 1). You should notice a significant difference in the amount of free space.

Here's an example of my storage after a cleaning operation, showing the considerable space recovered:

As you can observe, I recovered considerable storage space. By taking these simple steps, you can significantly extend the life and usability of your current computer, saving you money and the hassle of a new system!

DISM is a very powerful built-in tool and I recommend using it. Invoking and inspecting the various uses of DISM can be see by invoking it from caommand line as follows;


C:\Windows\System32>dism

Deployment Image Servicing and Management tool

Version: 10.0.26100.1150

DISM.exe [dism_options] {Imaging_command} [<Imaging_arguments>]

DISM.exe {/Image:<path_to_offline_image> | /Online} [dism_options]

         {servicing_command} [<servicing_arguments>]


DESCRIPTION:


  DISM enumerates, installs, uninstalls, configures, and updates features

  and packages in Windows images. The commands that are available depend

  on the image being serviced and whether the image is offline or running.



FFU COMMANDS:


  /Capture-Ffu            - Captures a physical disk image into a new FFU file.

  /Apply-Ffu              - Applies an .ffu image.

  /Split-Ffu              - Splits an existing .ffu file into multiple read-only

                            split FFU files.

  /Optimize-Ffu           - Optimizes a FFU file so that it can be applied to storage

                            of a different size.


WIM COMMANDS:


  /Apply-CustomDataImage  - Dehydrates files contained in the custom data image.

  /Capture-CustomImage    - Captures customizations into a delta WIM file on a

                            WIMBoot system. Captured directories include all

                            subfolders and data.

  /Get-WIMBootEntry       - Displays WIMBoot configuration entries for the

                            specified disk volume.

  /Update-WIMBootEntry    - Updates WIMBoot configuration entry for the

                            specified disk volume.

  /List-Image             - Displays a list of the files and folders in a

                            specified image.

  /Delete-Image           - Deletes the specified volume image from a WIM file

                            that has multiple volume images.

  /Export-Image           - Exports a copy of the specified image to another

                            file.

  /Append-Image           - Adds another image to a WIM file.

  /Capture-Image          - Captures an image of a drive into a new WIM file.

                            Captured directories include all subfolders and

                            data.

  /Get-MountedWimInfo     - Displays information about mounted WIM images.

  /Get-WimInfo            - Displays information about images in a WIM file.

  /Commit-Wim             - Saves changes to a mounted WIM image.

  /Unmount-Wim            - Unmounts a mounted WIM image.

  /Mount-Wim              - Mounts an image from a WIM file.

  /Remount-Wim            - Recovers an orphaned WIM mount directory.

  /Cleanup-Wim            - Deletes resources associated with mounted WIM

                            images that are corrupted.


GENERIC IMAGING COMMANDS:


  /Split-Image            - Splits an existing .wim file into multiple

                            read-only split WIM (SWM) files.

  /Apply-Image            - Applies an image.

  /Get-MountedImageInfo   - Displays information about mounted WIM and VHD

                            images.

  /Get-ImageInfo          - Displays information about images in a WIM, a VHD

                            or a FFU file.

  /Commit-Image           - Saves changes to a mounted WIM or VHD image.

  /Unmount-Image          - Unmounts a mounted WIM or VHD image.

  /Mount-Image            - Mounts an image from a WIM or VHD file.

  /Remount-Image          - Recovers an orphaned image mount directory.

  /Cleanup-Mountpoints    - Deletes resources associated with corrupted

                            mounted images.


IMAGE SPECIFICATIONS:


  /Online                 - Targets the running operating system.

  /Image                  - Specifies the path to the root directory of an

                            offline Windows image.


DISM OPTIONS:


  /English                - Displays command line output in English.

  /Format                 - Specifies the report output format.

  /WinDir                 - Specifies the path to the Windows directory.

  /SysDriveDir            - Specifies the path to the system-loader file named

                            BootMgr.

  /LogPath                - Specifies the logfile path.

  /LogLevel               - Specifies the output level shown in the log (1-4).

  /NoRestart              - Suppresses automatic reboots and reboot prompts.

  /Quiet                  - Suppresses all output except for error messages.

  /ScratchDir             - Specifies the path to a scratch directory.


For more information about these DISM options and their arguments, specify an

option immediately before /?.


  Examples:

    DISM.exe /Mount-Wim /?

    DISM.exe /ScratchDir /?

    DISM.exe /Image:C:\test\offline /?

    DISM.exe /Online /?

As far as cleaning is concerned, it may be evoked from the command line as follows:

C:\Windows\System32>Dism.exe /Online /Cleanup-Image /StartComponentCleanup

Deployment Image Servicing and Management tool
Version: 10.0.26100.1150

Image Version: 10.0.26100.4770

[==========================100.0%==========================]
The operation completed successfully.


Here is a widely read post on DISM from 11 years ago on this blog:


 

Saturday, July 5, 2025

How do you visualize glucose data from a glucose CGM report using Python?

Interpretation of data from the python code from my previous post must be exercised with caution. The program explicitly puts red dots over the curve to establish verification that the method indeed achieves its objective. We have seen that the image generated does show large red circles riding the graph. 

It is easy to show by reducing the size to 0, that the curve is traced by very tiny circles shown by an underlying red ness in the trace (zoom to see). These are shown for two the two radii assumed in the next figure.

 


However, a .CSV file is generated by the code. The graphing of this file in Microsoft Excel does not show any difference between the two cases, radius=2 and radius =0 as shown.

  


The reason is these curves (one by visualization and the other set by generated CSV file) are not using the same base.

1. The cv2.circle() visualization: This is what creates the glucose_trace_detected.jpg. 

2. The matplotlib.pyplot.plot() or scatter() visualization: This is what creates the glucose_value_mg_dL plo.

However, in the plotted graphs from CSV files we find gaps in the generated graph. They can indeed correspond to event marker positions. The red dot in the visualization is only for verifying that the entire graph is captured.

We will take a look at this possibility of getting the psotional data of events in the next post, as it gives us valuable information on event times.